File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,12 +360,15 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v
360360 final_field_typ := g.table.final_type (field.typ)
361361 sym := g.table.sym (final_field_typ)
362362 if sym.kind == .struct && sym.name != 'time.Time' {
363- subs << unsafe { node.sub_structs[int (final_field_typ)] }
364- unwrapped_c_typ := g.styp (final_field_typ.clear_flag (.option))
365- subs_unwrapped_c_typ << if final_field_typ.has_flag (.option) {
366- unwrapped_c_typ
367- } else {
368- ''
363+ if final_field_typ in node.sub_structs {
364+ subs << unsafe { node.sub_structs[int (final_field_typ)] }
365+
366+ unwrapped_c_typ := g.styp (final_field_typ.clear_flag (.option))
367+ subs_unwrapped_c_typ << if final_field_typ.has_flag (.option) {
368+ unwrapped_c_typ
369+ } else {
370+ ''
371+ }
369372 }
370373 } else if sym.kind == .array {
371374 // Handle foreign keys
@@ -377,7 +380,7 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v
377380 if final_field_typ.has_flag (.option) {
378381 opt_fields << arrs.len
379382 }
380- if node.sub_structs.len > 0 {
383+ if final_field_typ in node.sub_structs {
381384 arrs << unsafe { node.sub_structs[int (final_field_typ)] }
382385 }
383386 field_names << field.name
You can’t perform that action at this time.
0 commit comments