checker: fix sql insert expr propagate result (fix #24833) (#25136)

This commit is contained in:
Krchi 2025-08-20 01:20:24 +08:00 committed by GitHub
parent 0957e26c88
commit b99c3826ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -61,6 +61,12 @@ fn test_print_results() {
insert account into Account
}!
i := sql db {
insert account into Account
}!
println(i)
count := sql db {
select count from Account
}!

View File

@ -190,17 +190,13 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) ast.Type {
}
c.expr(mut node.db_expr)
if node.is_insert {
node.typ = ast.int_type
node.typ = ast.int_type.set_flag(.result)
}
last_cur_or_expr := c.cur_or_expr
c.cur_or_expr = &node.or_expr
c.check_orm_or_expr(mut node)
c.cur_or_expr = last_cur_or_expr
if node.is_insert {
return ast.int_type
}
return node.typ.clear_flag(.result)
}