Repository navigation
fix: ORM review nits (many to many result and query count, restore updated_at, update tests) - #38
Merged
Merged
Conversation
Contributor
Author
Bot reviewChecked: Blocking
Non-blocking
|
Contributor
Author
Fixer replyFixed in the latest commit, "fix: let the database decide which text ids match a stored row".
New tests:
Test results:
|
Contributor
Author
Bot reviewReviewed the full diff against Blocking None. Non-blocking
What I checked
|
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.
Small fixes from the reviews of #36 and #37. Bug fixes and tests only. No breaking changes, no version bump. One commit per item.
1.
sync()reported a delete that did not happenCOLLATE NOCASE), with stored'ABC'and'abc',sync(['ABC'])returneddetached: ['abc'].'abc'as the kept'ABC'), so the result was wrong.sync()andtoggle()read the rows again and report only the rows that are really gone. In the normal case there is no extra query.2. Weak test
isNotEmpty.['ABC', 'abc']) andr.detached(empty). Ther.detachedcheck is in the commit of item 1, because it fails without that fix.3. One query per text id
sync()andtoggle()ran one SELECT for each id.WHERE key IN (...)query reads the rows of all ids. Then each row is matched in Dart without case and without end spaces, like the database. A row with the exact text of an id goes only to that id. If a row matches no id this way (like'é'and'e'on an accent-insensitive MySQL or MariaDB column), only the ids with no row are checked one by one, like before. A test counts the queries (4 before, 2 now), and another test checks the accent case on MySQL and MariaDB.4.
restore()did not setupdated_atupdated_at, butrestore()did not.updated_at. Laravel sets it.restore()now setsupdated_atwhen the model has timestamps, in the database and in theupdatedAtfield. It uses a customupdated_atcolumn, and sets nothing withtimestamps: false. The query form (Blog().where(...).restore()) sets it too, like soft delete and like Laravel's query restore.5. Tests for
update()on a loaded modeltimestamps: false, and one with a customupdated_atcolumn (modified_at).updatedAtfield kept the old one, becausesetColumnValue()does not know the custom column.update()now sets the field directly, likesave()does. This fix is in the same commit.Tests
mainon my machine (a text column gets7for'007'after the number key tests). CI onmainis green, so it looks local only. These files pass when run on their own.