-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array order test case for sortObject #4005
Conversation
Thank you for detecting this. At the moment RxDB uses these hashes only for the developers security to not accidentially use an existing data store with a different schema without having done a migration. So it is not that big of a problem that the different browsers result in a different hash as long as they create the same hash each time for themself. However this should be fixed in the next major version, so we should add it to the todo list: https://github.com/pubkey/rxdb/blob/master/orga/before-next-major.md For your replication plugin you might want to craft your own schema hashes in the meantime. |
I agree. If you make sure that |
I added this to the todo list. |
* CHANGE Do not use hash for revisions * Remove the deprecated PouchDB RxStorage * REMOVE pouchdb RxStorage * FIX typing tests * FIX imports * FIX ci * FIX imports * FIX tests * FIX imports * REMOVe pouchdb from tests * REMOVE pouchdb scripts * FIX imports * FIX import * FIX tests * FIX tests * FIX tests * FIX lokijs tests * CHANGE (memory RxStorage) do not clean up database state on closing of the storage, only on `remove()` * FIX node example * FIX ci * FIX stuff * FIX ci * FIX foundationdb stuff * FIX stuff * FIX test * FIX t est * FIX stuff * REMOVE old `replication-couchdb` plugin. Rename `replication-couchdb-new` to `replication-couchdb`. * FIX angular replication * FIX websocket replication * FIX type * FIX stuff * FIX import * UPDATE stuff * FIX CouchDB replication: Use correct default fetch method * FIX vue * FIX stuff * FIX stuff * FIX ci * FIX vue * FIX ciu * aDD log to debug * FIX stuff * FIX tests * CHANGE use plain json errors inside of RxError parameters to make debugging easier. * FIX tests * REFACTOR error handling of RxStorageInstance.bulkWrite() * FIX types * FIX error * FIX test * ADD incremental write queue (#4186) * ADD incremental write queue * RMEOVE logs * FIX types * Remove depricated `skipIfSame` from `putAttachment()` * CHANGE immutable documents (#4189) * CHANGE immutable documents step1 * FIX tests * FIX more tests * FIX more tests * FIX more tests * FIX more tests * FIX tests * FIX tests * FIX docs * FIX tests * FIX tests * ADD changelog * FIX tests * FIX types * FIX deps * UPDATE typescript * UPDATE angular * UPDATE typescript * FIX typos * UPDATE node * FIX angular * UPDATE @types/node * REMOVE unmaintained babel-plugin-transform-async-to-promises * FIX angular tests * FIX babel confict * ADD changelog * REMOVE comment * UPDATE testcafe * TRY fix tests * FIX run headless * TRY fix stuff * TRY ajax timeout * IMPROVE error log * FIX stuff * FIX closing of replication * FIX todos * CHANGE `RxCollection.findByIds()` now returns a `RxQuery` (#4191) * CHANGE `RxCollection.findByIds()` now returns a `RxQuery` * ADD orga * FIX do not return deleted documents * FIX schema hashing should respect the sort order #4005 * FIX lint * CHANGE Prefix storage plugins with `storage-` like `rxdb/plugins/stor… (#4193) * CHANGE Prefix storage plugins with `storage-` like `rxdb/plugins/storage-dexie` * FIX remove more PouchDB stuff * FIX build * FIX imports * FIX types * FIX imports * FIX clear cache * FIX clear cache * FIX supabase example * FIX document cache to work with QuickJS * CHANGE prefix ci task names * FIX flutter * FIX tests * FIX types * REMOVE more pouchdb specific tests * REMOVE more pouchdb specific tests * FIX test * RENAME atomic->incremental (#4197) * RENAME atomic->incremental * ADD more incremental methods * FIX run hooks on remove * FIX format * ADD typings to the query selector * UPDATE orga * FIX build * FIX stuff * FIX mingo * FIX circular deps * TRY fix import * ADD notes * REFACTOR utils (#4204) * REFACTOR utils * REMOVE $all query type #4203 * Update package.json * Add missing mingo array operators (#4203) * ADD #4203 to changelog * Update dependency babel-loader to v8.3.0 (#4206) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency @types/node to v14.18.36 (#4207) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency apollo-server-express to v3.11.1 (#4205) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * 13.17.1 * Update dependency firebase to v9.15.0 (#4210) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency concurrently to v7.6.0 (#4208) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * REFACTOR use plain functions for replication plugins * FIX docs * FIX stuff * FIX stuff * FIX build * TRY fix types * FIX types * FIX graphql example * FIX * FIX import Co-authored-by: swnf <50806201+swnf@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * FIX ci Co-authored-by: swnf <50806201+swnf@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR contains:
A test case failing in Firefox but not Chrome
Describe the problem you have without this PR
I'm working on a replication library that compares the client's RxSchema hash with the one on the server side. I realized the hash provided by RxDB is not the same across browsers (Chrome, Firefox) if the schema contains an array of objects (an
anyOf
in my case). This could also be a problem in the future if a browser update changes the browser's implementation of the sort algorithm.Cause of the issue
src/util.ts has the following lines for sorting arrays:
It returns
1
if the left operand is an object and-1
otherwise. The spec has no constraints for the order ofa
andb
in the compare function. It seems to be different in Chrome and Firefox.Possible solutions
0
if one operand is not a string (sort
is stable, it will preserve the order in this case)Both solutions would be a breaking change.