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

checker,orm: skip compile-time error msg for fields tagged with [skip] and [sql: '-'] (#18700)

This commit is contained in:
Daniel Daudysh
2023-06-29 06:43:24 +03:00
committed by GitHub
parent 499d0526fc
commit f0fb86f76e
5 changed files with 44 additions and 31 deletions

View File

@ -18,12 +18,14 @@ struct Module {
[table: 'userlist']
struct User {
id int [primary; sql: serial]
id int [primary; sql: serial]
age int
name string [sql: 'username']
name string [sql: 'username']
is_customer bool
skipped_string string [skip]
skipped_string2 string [sql: '-']
skipped_string string [skip]
skipped_string2 string [sql: '-']
skipped_array []string [skip]
skipped_array2 []string [sql: '-']
}
struct Foo {
@ -50,6 +52,8 @@ fn test_use_struct_field_as_limit() {
age: 29
name: 'Sam'
skipped_string2: 'this should be ignored'
skipped_array: ['ignored', 'array']
skipped_array2: ['another', 'ignored', 'array']
}
sql db {
@ -65,6 +69,8 @@ fn test_use_struct_field_as_limit() {
assert users[0].age == 29
assert users[0].skipped_string == ''
assert users[0].skipped_string2 == ''
assert users[0].skipped_array == [], 'skipped because of the [skip] tag, used for both sql and json'
assert users[0].skipped_array2 == [], "should be skipped, because of the sql specific [sql: '-'] tag"
}
fn test_orm() {