checker, orm: add error for unchecked option multi return types, fix undefined behavior (#21106)

This commit is contained in:
Turiiya 2024-03-28 06:31:32 +01:00 committed by GitHub
parent f172a040ef
commit b98dca585c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 33 deletions

View file

@ -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'