pull/13374/head
parent
c9a8d6448d
commit
173b4652fb
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/orm_using_undefined_var_in_where_err.vv:24:35: error: undefined variable: `email`
|
||||
22 |
|
||||
23 | _ := sql db {
|
||||
24 | select from User where email == email
|
||||
| ~~~~~
|
||||
25 | }
|
||||
26 | }
|
|
@ -0,0 +1,26 @@
|
|||
import time
|
||||
import sqlite
|
||||
|
||||
struct User {
|
||||
id int [primary; sql: serial]
|
||||
created_at time.Time
|
||||
updated_at time.Time
|
||||
email string
|
||||
password string
|
||||
name string
|
||||
}
|
||||
|
||||
fn main() {
|
||||
db := sqlite.connect(':memory:') ?
|
||||
sql db {
|
||||
create table User
|
||||
}
|
||||
m := User{}
|
||||
sql db {
|
||||
insert m into User
|
||||
}
|
||||
|
||||
_ := sql db {
|
||||
select from User where email == email
|
||||
}
|
||||
}
|
|
@ -38,6 +38,13 @@ fn (mut p Parser) sql_expr() ast.Expr {
|
|||
query_one = true
|
||||
}
|
||||
}
|
||||
if e.right is ast.Ident {
|
||||
if !p.scope.known_var(e.right.name) {
|
||||
p.check_undefined_variables([e.left], e.right) or {
|
||||
return p.error_with_pos(err.msg, e.right.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mut has_limit := false
|
||||
|
|
Loading…
Reference in New Issue