Repository navigation
Conversation
* Track changed columns on locally created records Records created locally had an empty _changed field, so when a pull brought a record with the same id, per-column conflict resolution had nothing to keep and the remote version won entirely. Columns set in the create() builder are now recorded in _changed (for records with _status 'created'), so locally set columns win and the rest comes from the server. Servers ignore _changed. markLocalChangesAsSynced still resets it when the record is marked as synced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Decide whether to track create columns after the builder runs A create builder that assigned columns and then set _raw._status to 'synced' left those columns in _changed, so later pulls would keep the stale local values. Columns set in the builder are now collected while it runs and only added to _changed afterwards, if the record's final status is 'created'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @joker-777, thank you for this! I maintain NitromelonDB, a maintained fork of WatermelonDB (New Architecture, Nitro Modules). Our fork was rewritten in TypeScript (strict mode) to reduce the chance of bugs like this one slipping through, so I think the community would really benefit if you opened your PRs against it too. The relevant code is in If you don't have the time or would rather not, no worries at all, I'm happy to port it myself. Just let me know. Thanks a lot! |
This branch has not been deployed
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.
Records columns set while creating a record in its
_changedfield, so a conflict with a pulled record of the same id is resolved per column. Related issue: #1533.Changes
collection.create()builder are now recorded in_changedfor records with_status: 'created'. Before,_changedstayed empty until the first updateconflictResolvergets this per-column result asresolved, andlocal._changedlists the columns set locallycreatedrecords now carry a non-empty_changed. The backend docs already say servers must ignore it.markLocalChangesAsSyncedstill resets it to''_statusother thancreated(for example synced records built in a create builder), and_prepareCreateFromDirtyRaw, which sync usesTests
synchronize.test.js: creates a task offline, pulls the same id with different values, and checks the push payload and the final synced record. It fails on master, where_changedis""Modeltests updated for the new_changedvalues, plus tests for values equal to the default and for synced createsVerification
sqlite-nodesuite was left out because better-sqlite3 does not build on the host's Node; this change does not touch the adapters).flow checkis clean, and ESLint is clean on the changed filesapplyRemote.jsand its tests in separate places. They merge into master together without conflicts, and Jest passes on the result🤖 Generated with Claude Code