From 6799f3ac5c393904ce6dd0e491e7a247aae0b23c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 19 Sep 2021 04:48:28 +0300 Subject: [PATCH] orm: verify column name in updates --- vlib/v/checker/checker.v | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index a01f09b9dc..c231bef144 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 {