diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index 95ef6f5525..541a3a5bcc 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -49,6 +49,7 @@ fn test_use_struct_field_as_limit() { sam := User{ age: 29 name: 'Sam' + skipped_string2: 'this should be ignored' } sql db { @@ -60,6 +61,8 @@ fn test_use_struct_field_as_limit() { }! assert users.len == 1 + assert users[0].name == 'Sam' + assert users[0].age == 29 assert users[0].skipped_string == '' assert users[0].skipped_string2 == '' } diff --git a/vlib/v/gen/c/orm.v b/vlib/v/gen/c/orm.v index 8bff8eb1c9..846e07eaaf 100644 --- a/vlib/v/gen/c/orm.v +++ b/vlib/v/gen/c/orm.v @@ -404,6 +404,9 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v if attr.name == 'skip' { skip = true } + if attr.name == 'sql' && attr.arg == '-' { + skip = true + } } if !skip && !primary { fff << f @@ -693,6 +696,9 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, le if attr.name == 'skip' { skip = true } + if attr.name == 'sql' && attr.arg == '-' { + skip = true + } } if !skip { fields << field @@ -996,6 +1002,9 @@ fn (_ &Gen) filter_struct_fields_by_orm_attrs(fields []ast.StructField) []ast.St if attr.name == 'skip' { skip = true } + if attr.name == 'sql' && attr.arg == '-' { + skip = true + } } if !skip && !primary {