mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
9344c27021
commit
be1e40dac0
@ -45,6 +45,7 @@ const (
|
||||
'vlib/sqlite/sqlite_orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||
'vlib/vweb/tests/vweb_test.v',
|
||||
'vlib/vweb/request_test.v',
|
||||
'vlib/net/http/request_test.v',
|
||||
@ -83,6 +84,7 @@ const (
|
||||
'vlib/orm/orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||
'vlib/clipboard/clipboard_test.v',
|
||||
'vlib/vweb/tests/vweb_test.v',
|
||||
'vlib/vweb/request_test.v',
|
||||
|
@ -759,7 +759,9 @@ fn (mut g Gen) sql_select(node ast.SqlExpr, expr string, left string) {
|
||||
if node.is_array {
|
||||
g.write('_array')
|
||||
}
|
||||
g.writeln(';')
|
||||
if !g.inside_call {
|
||||
g.writeln(';')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
24
vlib/v/tests/sql_statement_inside_fn_call_test.v
Normal file
24
vlib/v/tests/sql_statement_inside_fn_call_test.v
Normal file
@ -0,0 +1,24 @@
|
||||
import sqlite
|
||||
|
||||
struct Movie {
|
||||
id int [primary]
|
||||
name string
|
||||
}
|
||||
|
||||
fn x(m Movie) int {
|
||||
return m.id
|
||||
}
|
||||
|
||||
fn test_sql_statement_inside_fn_call() {
|
||||
db := sqlite.connect(':memory:') or { panic('failed') }
|
||||
sql db {
|
||||
create table Movie
|
||||
}
|
||||
m := Movie{1, 'Maria'}
|
||||
sql db {
|
||||
insert m into Movie
|
||||
}
|
||||
dump(x(sql db {
|
||||
select from Movie where id == 1
|
||||
}))
|
||||
}
|
Loading…
Reference in New Issue
Block a user