1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

orm: verify column name in updates

This commit is contained in:
Alexander Medvednikov 2021-09-19 04:48:28 +03:00
parent e76be4ba37
commit 6799f3ac5c

View File

@ -7956,7 +7956,12 @@ fn (mut c Checker) sql_stmt_line(mut node ast.SqlStmtLine) ast.Type {
node.fields = fields
node.sub_structs = sub_structs.move()
for i, column in node.updated_columns {
field := node.fields.filter(it.name == column)[0]
x := node.fields.filter(it.name == column)
if x.len == 0 {
c.error('type `$table_sym.name` has no field named `$column`', node.pos)
continue
}
field := x[0]
node.updated_columns[i] = c.fetch_field_name(field)
}
if node.kind == .update {