Skip to content

Commit

Permalink
fix missing checks in vlib
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Mar 27, 2024
1 parent bb6dfab commit 57fecb3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vlib/orm/orm.v
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 57fecb3

Please sign in to comment.