@@ -301,7 +301,7 @@ def _is_comparison_context(self, ctx: Any) -> bool:
301301 def _has_comparison_pattern (self , ctx : Any ) -> bool :
302302 """Check if the expression text contains comparison patterns"""
303303 try :
304- text = self .get_context_text (ctx )
304+ text = self .get_context_text (ctx ). upper ()
305305 # Extended pattern matching for SQL constructs
306306 patterns = COMPARISON_OPERATORS + ["LIKE" , "IN" , "BETWEEN" , "ISNULL" , "ISNOTNULL" ]
307307 return any (op in text for op in patterns )
@@ -327,12 +327,14 @@ def _extract_field_name(self, ctx: Any) -> str:
327327 """Extract field name from comparison expression"""
328328 try :
329329 text = self .get_context_text (ctx )
330+ text_upper = text .upper ()
330331
331332 # Handle SQL constructs with keywords
332333 sql_keywords = ["IN(" , "LIKE" , "BETWEEN" , "ISNULL" , "ISNOTNULL" ]
333334 for keyword in sql_keywords :
334- if keyword in text :
335- candidate = text .split (keyword , 1 )[0 ].strip ()
335+ if keyword in text_upper :
336+ idx = text_upper .index (keyword )
337+ candidate = text [:idx ].strip ()
336338 return self .normalize_field_path (candidate )
337339
338340 # Try operator-based splitting
@@ -359,6 +361,7 @@ def _extract_operator(self, ctx: Any) -> str:
359361 """Extract comparison operator"""
360362 try :
361363 text = self .get_context_text (ctx )
364+ text_upper = text .upper ()
362365
363366 # Check SQL constructs first (order matters for ISNOTNULL vs ISNULL)
364367 sql_constructs = {
@@ -370,7 +373,7 @@ def _extract_operator(self, ctx: Any) -> str:
370373 }
371374
372375 for construct , operator in sql_constructs .items ():
373- if construct in text :
376+ if construct in text_upper :
374377 return operator
375378
376379 # Look for comparison operators
@@ -394,15 +397,16 @@ def _extract_value(self, ctx: Any) -> Any:
394397 """Extract value from comparison expression"""
395398 try :
396399 text = self .get_context_text (ctx )
400+ text_upper = text .upper ()
397401
398402 # Handle SQL constructs with specific parsing needs
399- if "IN(" in text :
403+ if "IN(" in text_upper :
400404 return self ._extract_in_values (text )
401- elif "LIKE" in text :
405+ elif "LIKE" in text_upper :
402406 return self ._extract_like_pattern (text )
403- elif "BETWEEN" in text :
407+ elif "BETWEEN" in text_upper :
404408 return self ._extract_between_range (text )
405- elif "ISNULL" in text or "ISNOTNULL" in text :
409+ elif "ISNULL" in text_upper or "ISNOTNULL" in text_upper :
406410 return None
407411
408412 # Standard operator-based extraction
@@ -526,16 +530,24 @@ def _extract_in_values(self, text: str) -> List[Any]:
526530
527531 def _extract_like_pattern (self , text : str ) -> str :
528532 """Extract pattern from LIKE clause"""
529- parts = text .split ("LIKE" , 1 )
530- return parts [1 ].strip ().strip ("'\" " ) if len (parts ) == 2 else ""
533+ idx = text .upper ().find ("LIKE" )
534+ if idx == - 1 :
535+ return ""
536+ return text [idx + 4 :].strip ().strip ("'\" " )
531537
532538 def _extract_between_range (self , text : str ) -> Optional [Tuple [Any , Any ]]:
533539 """Extract range values from BETWEEN clause"""
534- parts = text .split ("BETWEEN" , 1 )
535- if len (parts ) == 2 and "AND" in parts [1 ]:
536- range_values = parts [1 ].split ("AND" , 1 )
537- if len (range_values ) == 2 :
538- return (self ._parse_value (range_values [0 ].strip ()), self ._parse_value (range_values [1 ].strip ()))
540+ text_upper = text .upper ()
541+ between_idx = text_upper .find ("BETWEEN" )
542+ if between_idx == - 1 :
543+ return None
544+ after = text [between_idx + 7 :]
545+ after_upper = after .upper ()
546+ and_idx = after_upper .find ("AND" )
547+ if and_idx != - 1 :
548+ low = after [:and_idx ].strip ()
549+ high = after [and_idx + 3 :].strip ()
550+ return (self ._parse_value (low ), self ._parse_value (high ))
539551 return None
540552
541553
0 commit comments