mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
checker, orm: add error for unchecked option multi return types, fix undefined behavior (#21106)
This commit is contained in:
parent
f172a040ef
commit
b98dca585c
6 changed files with 66 additions and 33 deletions
|
@ -508,12 +508,13 @@ pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int,
|
|||
return error("references attribute needs to be in the format [references], [references: 'tablename'], or [references: 'tablename(field_id)']")
|
||||
}
|
||||
if attr.arg.contains('(') {
|
||||
ref_table, ref_field := attr.arg.split_once('(')
|
||||
if !ref_field.ends_with(')') {
|
||||
return error("explicit references attribute should be written as [references: 'tablename(field_id)']")
|
||||
if ref_table, ref_field := attr.arg.split_once('(') {
|
||||
if !ref_field.ends_with(')') {
|
||||
return error("explicit references attribute should be written as [references: 'tablename(field_id)']")
|
||||
}
|
||||
references_table = ref_table
|
||||
references_field = ref_field[..ref_field.len - 1]
|
||||
}
|
||||
references_table = ref_table
|
||||
references_field = ref_field[..ref_field.len - 1]
|
||||
} else {
|
||||
references_table = attr.arg
|
||||
references_field = 'id'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue