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,8 +759,10 @@ fn (mut g Gen) sql_select(node ast.SqlExpr, expr string, left string) {
|
|||
if node.is_array {
|
||||
g.write('_array')
|
||||
}
|
||||
if !g.inside_call {
|
||||
g.writeln(';')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut g Gen) parse_db_type(expr ast.Expr) SqlType {
|
||||
|
|
|
@ -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