Skip to content

Commit 7369603

Browse files
committed
fix(api): remove superfluous headquarters object from source seeder params
The `sources` seeder was failing with a "superfluous variables" error for the `headquarters` key. The logic correctly added the `headquarters_country_id` to the parameter map but failed to remove the original nested `headquarters` object. This change updates the seeder to remove the `headquarters` key from the map after its ID has been extracted, ensuring the parameter map exactly matches the SQL query and resolving the startup error.
1 parent 1ddc3a4 commit 7369603

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,13 @@ class DatabaseSeedingService {
196196
final source = Source.fromJson(data);
197197
final params = source.toJson();
198198

199-
// The `headquarters` field in the model is a nested `Country` object.
200-
// We store its ID in the `headquarters_country_id` column.
199+
// The `headquarters` field in the model is a nested `Country`
200+
// object. We extract its ID to store in the
201+
// `headquarters_country_id` column and then remove the original
202+
// nested object from the parameters to avoid a "superfluous
203+
// variable" error.
201204
params['headquarters_country_id'] = source.headquarters?.id;
205+
params.remove('headquarters');
202206

203207
// Ensure optional fields exist for the postgres driver.
204208
params.putIfAbsent('description', () => null);

0 commit comments

Comments
 (0)