From 4a2c3ce7dc28c122e28c1e22bf8afd771c689b0a Mon Sep 17 00:00:00 2001 From: Swastik Date: Sun, 19 Jan 2025 00:36:35 +0530 Subject: [PATCH] add more check --- vlib/v/checker/infix.v | 2 +- .../checker/tests/orm_op_with_option_and_none.out | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/vlib/v/checker/infix.v b/vlib/v/checker/infix.v index d2b0b94457f20b..25f62660768fc6 100644 --- a/vlib/v/checker/infix.v +++ b/vlib/v/checker/infix.v @@ -781,7 +781,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { if typ != ast.no_type { typ_sym := c.table.sym(typ) op := node.op.str() - if left_type.has_flag(.option) { + if left_type.has_flag(.option) && !c.inside_sql { c.error('${node.left} is an Optional, it needs to be unwrapped first', node.left.pos()) } diff --git a/vlib/v/checker/tests/orm_op_with_option_and_none.out b/vlib/v/checker/tests/orm_op_with_option_and_none.out index 29aeb2dcfb2129..01ee85cbe75fb2 100644 --- a/vlib/v/checker/tests/orm_op_with_option_and_none.out +++ b/vlib/v/checker/tests/orm_op_with_option_and_none.out @@ -47,17 +47,3 @@ vlib/v/checker/tests/orm_op_with_option_and_none.vv:45:30: warning: comparison w | ~~ 46 | }! 47 | -vlib/v/checker/tests/orm_op_with_option_and_none.vv:49:25: error: name is an Optional, it needs to be unwrapped first - 47 | - 48 | _ := sql db { - 49 | select from Foo where name is none - | ~~~~ - 50 | }! - 51 | -vlib/v/checker/tests/orm_op_with_option_and_none.vv:53:25: error: name is an Optional, it needs to be unwrapped first - 51 | - 52 | _ := sql db { - 53 | select from Foo where name !is none - | ~~~~ - 54 | }! - 55 | }