Skip to content

Commit 0056d55

Browse files
authored
markused: support orm or expr (fix #24040) (#24059)
1 parent 22414eb commit 0056d55

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

cmd/tools/vtest-self.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const skip_with_fsanitize_memory = [
171171
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
172172
'vlib/v/tests/orm_create_several_tables_test.v',
173173
'vlib/v/tests/orm_update_test.v',
174+
'vlib/v/tests/orm_or_test.v',
174175
'vlib/vweb/tests/vweb_test.v',
175176
'vlib/vweb/csrf/csrf_test.v',
176177
'vlib/net/http/request_test.v',
@@ -196,6 +197,7 @@ const skip_with_fsanitize_address = [
196197
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
197198
'vlib/v/tests/orm_create_several_tables_test.v',
198199
'vlib/v/tests/orm_update_test.v',
200+
'vlib/v/tests/orm_or_test.v',
199201
]
200202
const skip_with_fsanitize_undefined = [
201203
'do_not_remove',
@@ -209,6 +211,7 @@ const skip_with_fsanitize_undefined = [
209211
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
210212
'vlib/v/tests/orm_create_several_tables_test.v',
211213
'vlib/v/tests/orm_update_test.v',
214+
'vlib/v/tests/orm_or_test.v',
212215
'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info'
213216
]
214217
const skip_on_ubuntu_musl = [
@@ -251,6 +254,7 @@ const skip_on_ubuntu_musl = [
251254
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
252255
'vlib/v/tests/orm_create_several_tables_test.v',
253256
'vlib/v/tests/orm_update_test.v',
257+
'vlib/v/tests/orm_or_test.v',
254258
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
255259
'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
256260
'vlib/v/tests/fns/fn_literal_type_test.v',

vlib/v/markused/walker.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ pub fn (mut w Walker) stmt(node_ ast.Stmt) {
251251
}
252252
ast.SqlStmt {
253253
w.expr(node.db_expr)
254+
w.expr(node.or_expr)
254255
for line in node.lines {
255256
w.expr(line.where_expr)
256257
w.exprs(line.update_exprs)
@@ -522,6 +523,7 @@ fn (mut w Walker) expr(node_ ast.Expr) {
522523
}
523524
ast.SqlExpr {
524525
w.expr(node.db_expr)
526+
w.expr(node.or_expr)
525527
w.expr(node.offset_expr)
526528
w.expr(node.order_expr)
527529
w.expr(node.limit_expr)

vlib/v/tests/orm_or_test.v

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import db.sqlite
2+
import math
3+
4+
struct Counter {
5+
id int @[primary; sql: serial]
6+
f f64
7+
}
8+
9+
fn test_orm_or_block() {
10+
db := sqlite.connect(':memory:') or { panic(err) }
11+
12+
sql db {
13+
drop table Counter
14+
} or { println(math.e) } // this should compile
15+
16+
x := sql db {
17+
select from Counter
18+
} or {
19+
[Counter{
20+
f: math.pi
21+
}]
22+
}
23+
assert x[0].f == math.pi
24+
}

0 commit comments

Comments
 (0)