Skip to content

Commit b99c382

Browse files
authored
checker: fix sql insert expr propagate result (fix #24833) (#25136)
1 parent 0957e26 commit b99c382

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

vlib/orm/orm_result_test.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ fn test_print_results() {
6161
insert account into Account
6262
}!
6363

64+
i := sql db {
65+
insert account into Account
66+
}!
67+
68+
println(i)
69+
6470
count := sql db {
6571
select count from Account
6672
}!

vlib/v/checker/orm.v

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,13 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) ast.Type {
190190
}
191191
c.expr(mut node.db_expr)
192192
if node.is_insert {
193-
node.typ = ast.int_type
193+
node.typ = ast.int_type.set_flag(.result)
194194
}
195195
last_cur_or_expr := c.cur_or_expr
196196
c.cur_or_expr = &node.or_expr
197197
c.check_orm_or_expr(mut node)
198198
c.cur_or_expr = last_cur_or_expr
199199

200-
if node.is_insert {
201-
return ast.int_type
202-
}
203-
204200
return node.typ.clear_flag(.result)
205201
}
206202

0 commit comments

Comments
 (0)