Conversation
…g and incorrect ROM grouping - Add migration 0071 to fix sibling_roms view: add guard against empty string matching for fs_name_no_tags - Fix group_by_meta_id in filter_roms: use func.nullif to treat empty fs_name_no_tags as NULL in grouping key - Add group_by_meta_id support to get_roms_scalar - Add tests for sibling matching behavior with empty/non-empty fs_name_no_tags Co-authored-by: gantoine <[email protected]>
Greptile SummaryThis PR fixes a 500 error triggered when loading platforms that contain ROMs whose filenames start with region/format tags (e.g., Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["ROM filename\ne.g. (Japan) Sonic Jam.iso"] --> B{"fs_name_no_tags\nvalue?"}
B -- "empty string ''" --> C["NULLIF returns NULL"]
B -- "non-empty\ne.g. 'Sonic Jam'" --> D["NULLIF returns value"]
C --> E["_create_metadata_id_case: id_column IS NULL\n→ returns NULL (no key)"]
D --> F["_create_metadata_id_case: id_column IS NOT NULL\n→ returns 'fs-platformId-Sonic Jam'"]
E --> G["COALESCE falls through\nto romm-platformId-romId (unique)"]
F --> H["All ROMs with same fs_name_no_tags\ngrouped together correctly"]
G --> I["group_by_meta_id:\neach ROM gets its own group ✓"]
H --> J["group_by_meta_id:\nregion variants grouped correctly ✓"]
subgraph "sibling_roms VIEW fix"
K["r1.fs_name_no_tags = r2.fs_name_no_tags\nAND r1.fs_name_no_tags != ''"]
L["'' = '' was TRUE\n→ O(N²) false siblings"]
M["Now guarded: '' skipped\n→ no cross-product match"]
L --> M
end
Last reviewed commit: e3d9bfe |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
ROMs with filenames starting with region/format tags (e.g.,
(Japan) Sonic Jam.iso) produce an emptyfs_name_no_tags. Migration0069introducedfs_name_no_tagsmatching to thesibling_romsview without guarding against empty strings — causing"" = ""to match every such ROM against every other on the same platform, creating O(N²) sibling rows and query timeouts. The same empty string also poisoned thegroup_by_meta_idgrouping key, collapsing all unmatched tag-prefixed ROMs into a single group.Changes
0071_sibling_roms_nonempty_fs_namemigration — addsAND r1.fs_name_no_tags != ''to thesibling_romsview join condition, so empty strings no longer produce a cross-product of false siblings:filter_roms/group_by_meta_id— wrapsfs_name_no_tagsinNULLIF(..., '')when building thecoalescepartition key, so empty-named ROMs fall through to their uniqueromm-<platform_id>-<id>fallback key instead of all sharingfs-<platform_id>-:get_roms_scalar— passesgroup_by_meta_idthrough from**kwargstofilter_roms.Tests — three new cases covering: empty
fs_name_no_tagsnot producing siblings, non-empty matching names producing siblings, andgroup_by_meta_idreturning all ROMs (not just 1) when all have emptyfs_name_no_tags.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.