mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ORM fixes
This commit is contained in:
@ -41,7 +41,6 @@ fn (p mut Parser) select_query(fn_ph int) string {
|
||||
p.sql_params = []
|
||||
if false {}
|
||||
p.sql_types = []
|
||||
|
||||
mut q := 'select '
|
||||
p.check(.key_select)
|
||||
n := p.check_name()
|
||||
@ -91,8 +90,8 @@ fn (p mut Parser) select_query(fn_ph int) string {
|
||||
// `where` statement
|
||||
if p.tok == .name && p.lit == 'where' {
|
||||
p.next()
|
||||
_, expr := p.tmp_expr()
|
||||
p.is_sql = true
|
||||
_, expr := p.tmp_expr()
|
||||
p.is_sql = false
|
||||
q += ' where ' + expr
|
||||
}
|
||||
@ -100,8 +99,8 @@ fn (p mut Parser) select_query(fn_ph int) string {
|
||||
mut query_one := false
|
||||
if p.tok == .name && p.lit == 'limit' {
|
||||
p.next()
|
||||
_, limit := p.tmp_expr()
|
||||
p.is_sql = true
|
||||
_, limit := p.tmp_expr()
|
||||
p.is_sql = false
|
||||
q += ' limit ' + limit
|
||||
// `limit 1` means we are getting `?User`, not `[]User`
|
||||
@ -111,7 +110,7 @@ fn (p mut Parser) select_query(fn_ph int) string {
|
||||
}
|
||||
println('sql query="$q"')
|
||||
p.cgen.insert_before('// DEBUG_SQL prefix: $qprefix | fn_ph: $fn_ph | query: "$q" ')
|
||||
|
||||
|
||||
if n == 'count' {
|
||||
p.cgen.set_placeholder(fn_ph, 'pg__DB_q_int(')
|
||||
p.gen(', tos2("$q"))')
|
||||
@ -171,12 +170,12 @@ for (int i = 0; i < ${qprefix}rows.len; i++) {
|
||||
')
|
||||
p.cgen.resetln('${qprefix}arr_$tmp')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if n == 'count' {
|
||||
return 'int'
|
||||
} else if query_one {
|
||||
opt_type := 'Option_$table_name'
|
||||
} else if query_one {
|
||||
opt_type := 'Option_$table_name'
|
||||
p.cgen.typedefs << 'typedef Option $opt_type;'
|
||||
p.table.register_builtin( opt_type )
|
||||
return opt_type
|
||||
|
Reference in New Issue
Block a user