Skip to content

fix: preserve insertion order of object names#409

Merged
brickbots merged 1 commit into
brickbots:mainfrom
mrosseel:fix-bright-star-name-order
Apr 18, 2026
Merged

fix: preserve insertion order of object names#409
brickbots merged 1 commit into
brickbots:mainfrom
mrosseel:fix-bright-star-name-order

Conversation

@mrosseel
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Bright Star catalog (and other multi-name objects) displaying names in inconsistent, run-to-run varying order — e.g. "Str3 Alpha Crucis, Acrux" instead of the source-data order "Str3 Acrux, Alpha Crucis".
  • Root cause: get_object_id_to_names used list(set(...)) to deduplicate, which is non-deterministic due to Python hash randomization. Also, the underlying SELECT had no ORDER BY.
  • Fix: use dict.fromkeys() to dedupe while preserving insertion order, and add ORDER BY rowid to guarantee SQLite returns rows in insertion order.

Reported by waterman480 on Discord — order of common vs. Latin names was flipping between runs on v2.4 and v2.5.

Test plan

  • Launch PiFinder, navigate to Bright Star catalog, verify Str2/3/6/7/8 show common name first (e.g. "Str3 Acrux, Alpha Crucis", "Str6 Alcor, 80 Ursae Majoris")
  • Restart the app and confirm the order is stable across runs
  • Spot-check other catalogs with multiple aka names (NGC/Messier) to confirm no regressions

🤖 Generated with Claude Code

The get_object_id_to_names query used list(set(...)) to deduplicate
names, which produces non-deterministic order due to Python hash
randomization. This caused Bright Star catalog entries (and others with
multiple names) to display names in inconsistent order, varying between
runs — e.g. "Str3 Alpha Crucis, Acrux" instead of the expected
"Str3 Acrux, Alpha Crucis".

Use dict.fromkeys() to deduplicate while preserving order, and add
ORDER BY rowid to the query so SQLite returns names in insertion order.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brickbots brickbots merged commit 5d892d8 into brickbots:main Apr 18, 2026
1 check passed
brickbots pushed a commit that referenced this pull request Apr 18, 2026
The get_object_id_to_names query used list(set(...)) to deduplicate
names, which produces non-deterministic order due to Python hash
randomization. This caused Bright Star catalog entries (and others with
multiple names) to display names in inconsistent order, varying between
runs — e.g. "Str3 Alpha Crucis, Acrux" instead of the expected
"Str3 Acrux, Alpha Crucis".

Use dict.fromkeys() to deduplicate while preserving order, and add
ORDER BY rowid to the query so SQLite returns names in insertion order.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants