Skip to content

chore: include table name in SQLSerializable duplicate-key warning - #350

Merged
sstromat merged 1 commit into
mainfrom
sqlserializable-warning-includes-table
Aug 3, 2026
Merged

chore: include table name in SQLSerializable duplicate-key warning#350
sstromat merged 1 commit into
mainfrom
sqlserializable-warning-includes-table

Conversation

@sstromat

@sstromat sstromat commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Reported during real-QGIS testing: an emission calc for EngineTestSource produced ~180 warnings all shaped like:

Already found entry with key 'None'. Replacing existing entry.

The message doesn't say WHICH SQL-backed table is producing the duplicate keys, so tracing back to the culprit table requires running under a debugger or grepping every SQLSerializable subclass. Any of the reference tables loaded during a calc run (tbl_InvMeteo, default_aircraft, default_aircraft_engine_ei, engine_test_events, shapes_area_sources, etc.) could be the source.

Diagnostic upgrade: include self._table_name in the warning. New shape:

Already found entry with key 'None' in table 'tbl_InvMeteo'.
Replacing existing entry.

Now the offending table is named at each occurrence, so a follow-up audit of the schema for that specific table can proceed directly.

The str(key) cast is preserved as-is (already handled None properly).

Not touched

This is only a diagnostic upgrade. The underlying condition (some table having a nullable or non-unique inferred primary key) persists; each table where this fires still silently deduplicates its in-memory entries down to one representative row per repeated key. Fixing individual tables is separate follow-up work once the warning names them.

Tests

No new tests. The change is a log-format tweak; no test asserts the old string (verified with grep). Existing test suite unaffected.

Reported during real-QGIS testing: an emission calc for
EngineTestSource produced ~180 warnings all shaped like:

    Already found entry with key 'None'. Replacing existing entry.

The message doesn't say WHICH SQL-backed table is producing the
duplicate keys, so tracing back to the culprit table requires
running under a debugger or grepping every SQLSerializable subclass.
Any of the reference tables loaded during a calc run (tbl_InvMeteo,
default_aircraft, default_aircraft_engine_ei, engine_test_events,
shapes_area_sources, etc.) could be the source.

Diagnostic upgrade: include self._table_name in the warning.
New shape:

    Already found entry with key 'None' in table 'tbl_InvMeteo'.
    Replacing existing entry.

Now the offending table is named at each occurrence, so a follow-up
audit of the schema for that specific table can proceed directly.

The str(key) cast is preserved as-is (already handled None properly).

Not touched
-----------

This is only a diagnostic upgrade. The underlying condition (some
table having a nullable or non-unique inferred primary key)
persists; each table where this fires still silently deduplicates
its in-memory entries down to one representative row per repeated
key. Fixing individual tables is separate follow-up work once the
warning names them.

Tests
-----

No new tests. The change is a log-format tweak; no test asserts the
old string (verified with grep). Existing test suite unaffected.
@sstromat
sstromat merged commit 5476712 into main Aug 3, 2026
1 check passed
@sstromat
sstromat deleted the sqlserializable-warning-includes-table branch August 3, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant