Repository navigation
fix: return cards and decks ordered by id - #89
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The list queries had no ORDER BY, so Postgres returned rows in heap order. An UPDATE writes the new row version after the existing ones, so after a PUT the list endpoints returned the updated rows last. advanced-alchemy's
upsert_manyre-reads updated rows with an unorderedget_many, which meant the PUT response could also come back reversed.test_create_cardsandtest_update_cardscompare whole lists in a fixed order and failed intermittently on a reused database.Changes:
CardsRepository.list_for_deckorders byCard.id.CardsRepository.upsert_cardssorts the upserted rows by id in Python, sinceupsert_manyhas noorder_by.DecksRepository.list_decksorders byDeck.id.ListDecksUseCasecalls it in place of the bareget_many().Tests:
test_cards_ordered_by_id_after_updatePUTs two cards in reverse id order and checks that the PUT response and the list both come back ordered by id.test_list_decks_ordered_by_id_after_updateupdates the first of two decks and checks the order of the deck list.Both new tests fail on main on every run, on a fresh database too, because the updated row versions land after the untouched ones.