@@ -116,6 +116,12 @@ fn test_expr(column_name: &str, table_name: &str, expr: &ast::Expr) -> Option<Nu
116
116
ast:: Expr :: InList { lhs, .. } if expr_matches_name ( column_name, table_name, lhs) => {
117
117
return Some ( NullableResult :: NotNull ) ;
118
118
}
119
+ ast:: Expr :: Like { lhs, rhs, .. }
120
+ if expr_matches_name ( column_name, table_name, lhs)
121
+ || expr_matches_name ( column_name, table_name, rhs) =>
122
+ {
123
+ return Some ( NullableResult :: NotNull )
124
+ }
119
125
// column is null
120
126
ast:: Expr :: Binary ( left, ast:: Operator :: Is , right)
121
127
if * * right == ast:: Expr :: Literal ( ast:: Literal :: Null )
@@ -362,4 +368,24 @@ mod tests {
362
368
Some ( NullableResult :: NotNull )
363
369
) ;
364
370
}
371
+
372
+ #[ test]
373
+ fn support_like_operator ( ) {
374
+ assert_eq ! (
375
+ is_column_nullable( "id" , "foo" , "select * from foo f where id like ?" ) ,
376
+ Some ( NullableResult :: NotNull )
377
+ ) ;
378
+ assert_eq ! (
379
+ is_column_nullable( "id" , "foo" , "select * from foo f where id not like ?" ) ,
380
+ Some ( NullableResult :: NotNull )
381
+ ) ;
382
+ assert_eq ! (
383
+ is_column_nullable( "id" , "foo" , "select * from foo f where ? like id" ) ,
384
+ Some ( NullableResult :: NotNull )
385
+ ) ;
386
+ assert_eq ! (
387
+ is_column_nullable( "id" , "foo" , "select * from foo f where ? not like id" ) ,
388
+ Some ( NullableResult :: NotNull )
389
+ ) ;
390
+ }
365
391
}
0 commit comments