Module ilike_to_like_transformer

Module ilike_to_like_transformer 

Source
Expand description

ILIKE to LIKE transformer

This transformer converts ILIKE (case-insensitive LIKE) operators to standard LIKE operators by wrapping both sides in UPPER() function calls.

§Problem

PostgreSQL-style ILIKE is convenient for case-insensitive pattern matching:

SELECT * FROM users WHERE email ILIKE '%@GMAIL.COM'

But not all SQL engines support ILIKE natively.

§Solution

Transform ILIKE to UPPER(col) LIKE UPPER(pattern):

-- Input
WHERE email ILIKE '%@gmail.com'

-- Output
WHERE UPPER(email) LIKE UPPER('%@gmail.com')

§Algorithm

  1. Traverse the entire AST
  2. Find all BinaryOp expressions with “ILIKE” operator
  3. Replace with LIKE operator and wrap both sides in UPPER()
  4. Recursively handle all clauses (WHERE, SELECT, HAVING, etc.)

Structs§

ILikeToLikeTransformer
Transformer that converts ILIKE to UPPER() LIKE UPPER()