fix: use key-order-independent comparison in equals methods#467
Merged
Conversation
`Inspected.equals()`, `ColumnInfo.equals()`, and `PostgreSQL.equals()` all used `JSON.stringify` for comparison, which is sensitive to object key order. When two databases have the same table columns in different physical order, the `columns` object serialises differently, making the table appear modified. This cascades through `add_dependents_for_modified` to spuriously drop and recreate dependent views, even when the views themselves are identical. Replace `JSON.stringify` comparisons with the existing `isEqual` utility, which sorts keys before comparing.
…diff fix: use key-order-independent comparison in `equals` methods
|
@felamaslen is attempting to deploy a commit to the mmkal Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
|
Thank you, this definitely looks sensible. I've approved the workflow to see if all the existing tests pass too. |
Contributor
Author
|
@mmkal any progress here? |
Owner
|
@felamaslen merged but having some trouble publishing, will let you know when I hear from npm support |
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.
Closes #466
Inspected.equals(),ColumnInfo.equals(), andPostgreSQL.equals()all usedJSON.stringifyfor comparison, which is sensitive to object key order. When two databases have the same table columns in different physical order (e.g. due to migrations adding columns at different times), thecolumnsobject serialises differently, causing the table to appear "modified". This cascades throughadd_dependents_for_modifiedto spuriously drop and recreate dependent views — even when the views themselves are semantically identical and explicitly list their columns.The fix replaces
JSON.stringifycomparisons with the existingisEqualutility, which sorts object keys before comparing.Views using
SELECT *are still correctly recreated, since Postgres expandsSELECT *into the physical column order, producing genuinely different view definitions.