-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Describe the bug
When using OfflineFirstWithSupabaseModel with nested relationships, Brick generates a Supabase insert/update that includes nested objects even when they are null. This causes errors like:
Could not find the 'assoc' column of 'tables' in the schema cache
insert or update on table violates foreign key constraint
The intended behavior is to serialize only the foreign key column when the nested object is null.
Minimal reproducible example
@ConnectOfflineFirstWithSupabase(
supabaseConfig: SupabaseSerializable(tableName: "model_a")
)
@MappableClass()
class ModelA extends OfflineFirstWithSupabaseModel with ModelAMappable {
final String id;
@Supabase(foreignKey: "model_a_child1_id_fkey")
final Child1? child1;
@Supabase(foreignKey: "model_a_child2_id_fkey")
final Child2? child2;
@Sqlite(ignore: true)
String? get child1Id => child1?.id;
@Sqlite(ignore: true)
String? get child2Id => child2?.id;
ModelA({
required this.id,
this.child1,
this.child2,
});
}
@MappableClass()
class Child1 extends OfflineFirstWithSupabaseModel with Child1Mappable {
final String id;
Child1({required this.id});
}
@MappableClass()
class Child2 extends OfflineFirstWithSupabaseModel with Child2Mappable {
final String id;
Child2({required this.id});
}Current behavior
If child1 is not null and child2 is null, Brick still construct upsert query with
child2:model_a_child2_id_fkey(*)....Expect behavior
Brick should ignore this query in the overall constructed Supabase query string.
Metadata
Metadata
Assignees
Labels
No labels