@@ -75,6 +75,10 @@ pub(crate) fn to_df_boolean_expr(expr: &BooleanExpression) -> Expr {
7575 expression,
7676 pattern,
7777 } => create_like_expr ( expression, pattern, false ) ,
78+ BE :: ILike {
79+ expression,
80+ pattern,
81+ } => create_like_expr ( expression, pattern, true ) ,
7882 BE :: Contains {
7983 expression,
8084 substring,
@@ -476,6 +480,85 @@ mod tests {
476480 }
477481 }
478482
483+ #[ test]
484+ fn test_boolean_expr_ilike ( ) {
485+ let expr = BooleanExpression :: ILike {
486+ expression : ValueExpression :: Property ( PropertyRef {
487+ variable : "p" . into ( ) ,
488+ property : "name" . into ( ) ,
489+ } ) ,
490+ pattern : "alice%" . into ( ) ,
491+ } ;
492+
493+ if let Expr :: Like ( like_expr) = to_df_boolean_expr ( & expr) {
494+ assert ! ( !like_expr. negated, "Should not be negated" ) ;
495+ assert ! (
496+ like_expr. case_insensitive,
497+ "ILIKE should be case insensitive"
498+ ) ;
499+ assert_eq ! ( like_expr. escape_char, None , "Should have no escape char" ) ;
500+ match * like_expr. expr {
501+ Expr :: Column ( ref col_expr) => {
502+ assert_eq ! ( col_expr. name( ) , "p__name" ) ;
503+ }
504+ other => panic ! ( "Expected column expression, got {:?}" , other) ,
505+ }
506+ // Check pattern is a literal
507+ match * like_expr. pattern {
508+ Expr :: Literal ( ref scalar, _) => {
509+ let s = format ! ( "{:?}" , scalar) ;
510+ assert ! (
511+ s. contains( "alice%" ) ,
512+ "Pattern should be 'alice%', got: {}" ,
513+ s
514+ ) ;
515+ }
516+ other => panic ! ( "Expected literal pattern, got {:?}" , other) ,
517+ }
518+ } else {
519+ panic ! ( "Expected Like expression" ) ;
520+ }
521+ }
522+
523+ #[ test]
524+ fn test_boolean_expr_like_vs_ilike_case_sensitivity ( ) {
525+ // Test LIKE (case-sensitive)
526+ let like_expr = BooleanExpression :: Like {
527+ expression : ValueExpression :: Property ( PropertyRef {
528+ variable : "p" . into ( ) ,
529+ property : "name" . into ( ) ,
530+ } ) ,
531+ pattern : "Test%" . into ( ) ,
532+ } ;
533+
534+ if let Expr :: Like ( like) = to_df_boolean_expr ( & like_expr) {
535+ assert ! (
536+ !like. case_insensitive,
537+ "LIKE should be case-sensitive (case_insensitive = false)"
538+ ) ;
539+ } else {
540+ panic ! ( "Expected Like expression" ) ;
541+ }
542+
543+ // Test ILIKE (case-insensitive)
544+ let ilike_expr = BooleanExpression :: ILike {
545+ expression : ValueExpression :: Property ( PropertyRef {
546+ variable : "p" . into ( ) ,
547+ property : "name" . into ( ) ,
548+ } ) ,
549+ pattern : "Test%" . into ( ) ,
550+ } ;
551+
552+ if let Expr :: Like ( ilike) = to_df_boolean_expr ( & ilike_expr) {
553+ assert ! (
554+ ilike. case_insensitive,
555+ "ILIKE should be case-insensitive (case_insensitive = true)"
556+ ) ;
557+ } else {
558+ panic ! ( "Expected Like expression" ) ;
559+ }
560+ }
561+
479562 #[ test]
480563 fn test_boolean_expr_like_with_wildcard ( ) {
481564 let expr = BooleanExpression :: Like {
0 commit comments