-
Notifications
You must be signed in to change notification settings - Fork 584
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
Set Datatype #3669
Set Datatype #3669
Conversation
…ff/new-set-datatype
…erge og support in Mixed
Co-authored-by: Andrew Meyer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few suggestions, nothing major. Great job!
await realm.syncSession.uploadAllLocalChanges(); | ||
|
||
// make sure everything is in the database | ||
let integers = realm.objects(schema.name)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this name is a bit to generic, making the follow code way harder to read.
In general, I like a principe of using the camelCased schema name as local variable name of a single object pulled from the database, i.e. const car = realm.objects("Car")[0];
.
let integers = realm.objects(schema.name)[0]; | |
const syncedSetInt = realm.objects(schema.name)[0]; |
I don't know if SyncedSetInt
is the best schema name in this context, would it be possible to find a more "real life" schema name, to enhance the readability of the test?
* Set | ||
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Set.html } | ||
*/ | ||
interface Set<T> extends Collection<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense for this to be a class
instead of an interface? (that way we can avoid lines 368 - 370)
interface Set<T> extends Collection<T> { | |
class Set<T> extends Collection<T> { |
Do we support construction and assignment of a set property by passing in a JS Set? const values = new Set();
values.add(1).add(2).add(3);
const realm = new Realm({ schema: [{ name: "Thing", properties: { values: "int<>" } }] });
realm.write(() => {
realm.create("Thing", { values });
}); If no, it would be great if we did. I imagine users what to buffer values in a JS Set before adding them to a database. |
Co-authored-by: Kræn Hansen <[email protected]>
…ff/new-set-datatype
…ff/new-set-datatype
* Cesarvr/porting mixed to jsc (#3655) * Porting the Mixed type to JSC * Formatting files * Fixing linking problems with where multiple static values collide at compile time. Mi first solution just fixed the compile error but crashed at runtime. I end up wrapping the TypeDeduction class into a Singleton, this way we can be sure that it lazy load the maps and keeps the map alive the rest of the lifecycle. * We don't need this guard * Fixing error message when the user insert incorrect values into the Mixed type. * Changing JS value name for Value to improve the clarity. * Quick change to trigger the CI Co-authored-by: Cesar Valdez <[email protected]> * core update 2021-03-24 (#3661) * Add SSL configuration options to sync configuration. (#3662) * Add SSL configuration options to sync configuration. * Datatype: UUID (#3482) * UUID: schema and node.js * Mock UUID JS class implemented. Test extended with type & content compare. to/from logic changed to a working solution (can be optimized). Test-packages removed. * Accessors reverted to non-string conversion, with required changes (input welcome). * Test cases expanded. * Reintroduce query-specific tests for UUID (with necessary addition to get_type_of). * query-tests added for UUID (and ObjectId, as this was currently missing). * JSC accessors implemented (UNTESTED due to RN build state). * uuid mock updated with fromExtendedJSON * query-tests for UUID & ObjectId extended with optional schemas * UUID.generate() returns a Buffer, as ObjectId does. * local bson package used in favor of mock. * temp bson package updated * added missing jsc is_uuid * using bson package UUID in tests * bson package (w. uuid) installed via github * UUID included in basic list-tests. * minor syntax changes * extended UUID query tests * tests working again... * bson deps updated to temp github path * uuid GH commit bumped * uuid GH commit bumped * expose BSON types on Realm.BSON (WIP) * test bson package updated * unused '_Binary' removed from realm constructor. * cleanup * uuid test cleanup * testUUIDQuery removed (covered by generic query tests) * integration-tests bson dependency removed * cluttering syntax changes "rolled back", for a clearer changeset. * removed unnecessary ObjectId/BSON import * reference to external bson package removed * mixed-test, pull Decimal128 & ObjectId from Realm * uuid sync test for single instances * bson depencendy remove from linkingobjects-tests * ObjectId & UUID added to testResultsSortedAllTypes * test_data.UUIDObject.json * List<UUID> test added to uuid-sync-tests * tab removed Co-authored-by: Andrew Meyer <[email protected]> * UUID case implemented in from_bson * const in favour of var Co-authored-by: Andrew Meyer <[email protected]> * bson package version bump * UUID as partition value (test does not include a complete roundtrip due to current limitations) * UUID support in Mixed Co-authored-by: Steffen Agger <[email protected]> Co-authored-by: Andrew Meyer <[email protected]> * Make AppClass::transport_generator initialized at const-init time (#3665) This fixes the "bad_function_call" issue where it was invoked while null (probably actually uninitialized). I'm not sure why it wasn't initialized yet, since the compiler should have ensured that it was. There is likely a compiler bug there but I'll need to dig in more. To work around that, I made it a simple function pointer, which lambdas can implicitly convert to, and all of that should be possible at const-init time (basically, it should be burned into the binary image with nothing happening at runtime). Unfortunately due to a different compiler bug, (https://developercommunity.visualstudio.com/t/const-init-of-function-pointers-from-lambdas/1383098), this requires putting a `+` in front of the lambda to explicitly decay it to a function pointer, rather than relying on the implicit conversion. * adding more comment * bson package updated to 4.3.0 (official release) (#3676) * Partition value tests (new test-server setup) (#3677) * Add tests of support types of partition values * docker image updated * pv-tests refactor, uuid partition-value-test reinstated, docker image & core updated to latest (query-tests updated accordingly) * "_id" marked as required in stich-setup * schemas updated to match new stitch-setup * react-test-app package.json updated (bson-package reference) * removed unnecessary template literal * Test: a more generic stitch app mounting * RealmAppImporter json-naming rolled back * wrong variable being changed * Jenkins: path for auth-integration-tests moved * typo * Jenkins update for "node Release" (test) * PR findings Co-authored-by: Kenneth Geisshirt <[email protected]> * Set Datatype (#3669) Set datatype support * Cesarvr/mixed for linked realm object (#3544) * Initial * Encapsulating the object linking features to make them reusable on the Mixed types. * Implementing the strategy registration process * Adding support for linked-objects for the polymorphic mixed type. * Added LinkedType support for mixed * refactoring the comment * Fixing some error validation when validating objects from other realms * Fixing wrong dates for disclaimer * Update src/js_links.hpp Co-authored-by: Nikola Irinchev <[email protected]> * Update src/js_links.hpp Co-authored-by: Nikola Irinchev <[email protected]> * Update src/common/mixed_type.hpp Co-authored-by: Nikola Irinchev <[email protected]> * Update src/js_links.hpp Co-authored-by: Nikola Irinchev <[email protected]> * Apply suggestions from code review Co-authored-by: Nikola Irinchev <[email protected]> * Adding Mixed query test * Add test for pushing class objects into a list Co-authored-by: Cesar Valdez <[email protected]> Co-authored-by: Nikola Irinchev <[email protected]> Co-authored-by: Andrew Meyer <[email protected]> Co-authored-by: Cesar Valdez <[email protected]> * Updating the error message when the user pass wrong object instances as Mixed values. * Removed testNewClassObjectPush, which is covered by testClassObjectCreation in master. (#3693) * Politely ask docker to clean up the created image after use. (#3691) * Upgrade to Realm Core v11.0.0-beta.4 (#3695) * Enable Realm.Set.get(). More testing. * Test set of mixed * Clean up FIXME:MIXED (#3703) * Clean up FIXME:MIXED * Split tests of mixed into sync and non-sync * Dictionaries V1 (#3631) * initial * Adding support for custom dictionary schema definition, where the user can constrain the value of the dictionary to a certain type. * Adding the testing framework to test C++ * Adding support for typed schemas. * Adding error checking to the dictionaries. * Initial live-object implementation * Adding test to make sure we offer a live-object dictionary and some error handling test. * Refactoring Dictionary and adding some more tests * Adding more test like serialization and making sure our Dict behaves like an JS Object * Adding more test like serialization and making sure our Dict behaves like an JS Object * Adding more test like serialization and making sure our Dict behaves like an JS Object * small renaming, optimizing for the reader * Adding more types to the Map of types. * Refactoring the way we add Getters/Setters into a plain object. This change is looking forward to the addition of notifications. * Adding listeners methods and tests. * index on dictionary: c894383 Refactoring the way we add Getters/Setters into a plain object. This change is looking forward to the addition of notifications. * Finish refactoring the dictionary listener/notification class * Finish refactoring the dictionary enumeration class * Implementation of remove_all_listener done [draft] * Refactoring: decomposing the dictionary files into reusable modules. * I moved the schema class for dictionary to another folder, need to rename the include on js_schema * Modularizing Dictionaries * first draft for key notifications * More drafting * Finishing notification draft * Small refactor and adding changeset transformation into JSON * Adding removing event listener by passing a JS function. * Adding some variation to the test case for removing listener, * Testing the stability of the Listeners API * Persisting the collection class, across calls to object_accessor. * Modularization of the Dictionary codebase. * More refactoring and renaming * Fixing object mutation problems * Adding entry to the changelog * Applying refactoring before fixing the notification bug * Fixing bug around objects not mutating accordly to reflect the dictionary update. * Adding more tests * Adding more tests * More Refactoring * Adding Headers * Adding @fronck suggestions. * Removing CPP test folder, agree with @fronck, if I want to include this at least we need to document how to use it. * Small refactor / renaming * Clang Formatting this stuff * Clang Formatting this stuff * Fixing the mess created by clang-formatter. * Adding more test to the object mutation. * Adding another test to check for out of bound * Adding the suggestions from the code review * Commenting query test until we fix the problem with realm-core * Removing query from tests * Removing hardcoded napi.h * Fixing compilation error <redefinition of object-link on Unbox method> by removing additional accessor class. * Isolating NodeJS specific functionality. * Porting Mixed to Javascript Core. * Merging the new version of mixed types that support JSC. * Adding object finalizers for JSC/NodeJS, this allow native object removal when the associated JS object is collected by the GC. * Removing guards for pragma once * Doing some risky refactoring, to acommodate the JSC object paradigm * Removing guard * Removing logs * Initial * Adding put method, to enable adding fields to the current dictionary. * Refactoring and abstracting the dictionary I/O, so it goes trough the Collection class where we can offer a common translation approach from JSValue to realm::Mixed and vice-versa. * Adding Data placeholder, this way we can create JS objects without backing C++ collection. * Adding C++ testing framework and class test to the project. * Adding CPP testing, now it should work by pointing to the workspace vendor/realm-core. * Adding testing to CPP and adding initial JSC support for dictionary * Upgrading to Catch2 in order to support development on Apple M1 * Refactoring NodeJS specific code for dictionaries. * Refactoring NodeJS dictionary implementation * Addng methods to the JSC class * Added methods, simple accessors and cpp test for JSC. * Refactoring JSC tests * Removing test binary * Improving tests and JSC method instantiation on JS Objects. * Improving documentation and fixing some bugs on NodeJS * Making NodeJS/JSC API's homogeneus, improving the tests for JSC and adding more tests. * Making JSC object compatible with the NodeJS implementation, adding more tests to the JSC object implementation. * Adding a finalizer function <A finalizer function is a function called by GC to dispose asociated C++ objects> * Formatting and cleaning * unit test for NodeJS/JSC now pass, and code now compiles using our *elegant* build script. Next step is to create a demo app to test Dict * Finally I can make it work for Android, now working on refactoring to make look good * refactoring/improving NodeJS methods and making sure that the new refactor also work for JSC/Android. * Addding error handling for writings outside of transaction. * Adding external support for Nodejs * Fixing some bugs * Refactoring and adding mutation to the objects. * Fixing some bugs * Added the put method * Refactoring and adding remove functionality * Porting Object mutation features to JSC * Refactoring of the JSC object creation process, so is more flexible to object mutation * Updating the documentation * Clang-formatting * Clang-formatting * Improving the testing docs * Removing dead module * Adding the deleted CMakeLists.txt * Improving memory ownership for the subscriber object. * Handling some edge cases of the JS VM shutting down while Realm is still sending updates. * Improving lifetime management for the collection of subscribers. * Update src/dictionary/builder/dictionary_builder.hpp Co-authored-by: FFranck <[email protected]> * Update src/dictionary/collection/collection.hpp Co-authored-by: FFranck <[email protected]> * Fixing the #pragma once placements * Update src/test/README.md Co-authored-by: FFranck <[email protected]> * Update src/dictionary/collection/collection.hpp Co-authored-by: FFranck <[email protected]> * Update src/dictionary/collection/notification.hpp Co-authored-by: FFranck <[email protected]> * Removing IOSTREAM * Adding comma missing after the merge * Minor fix for typed dictionaries * Adding docs * Adding proper documentation for Dictionaries * Improving the documentation * More documentation * Improving testing of JSC modules for dictionaries * Fixing test for dictionaries: testDictionary_Javascript_Object_Features * Fixing test for dictionaries: testDictionary_Javascript_Object_Features * Fixing test for dictionaries: testDictionary_Javascript_Object_Features & Dictionary.remove test * Fixing tests for iOS Co-authored-by: FFranck <[email protected]> Co-authored-by: Kenneth Geisshirt <[email protected]> Co-authored-by: cesar <[email protected]> * No Realm.Set.get() but use [] instead. * More testing of Realm.Set (#3702) * Test set of mixed * Enable [] on Realm.Set * Revert "More testing of Realm.Set (#3702)" This reverts commit d802d64. * No [] for Realm.Set. Test spread operator for Realm.Set. * Update tests/js/set-tests.js Co-authored-by: Kræn Hansen <[email protected]> * Update tests/js/set-tests.js Co-authored-by: Kræn Hansen <[email protected]> * Realm.Set.filtered() can take multiple arguments. * Fixed Set not exporting 'objectType' to Realm.schema when it contained scalar types (#3721) * "url" → "baseUrl" renamed on App configurations (#3725) * Renamed url to baseUrl * Updated tests to reflect the change * Updated the JSDoc * Adding a note to the changelog. * Sync integration tests (#3690) * Upgraded RealmAppImport to use the realm-cli * Changed to symlinked consumation for the electron app * Upgraded mocha-remote and fixed integration tests * Migrated to importing from "realm" * Major refactoring to the integration test harnesses * Simplified the react-native integration test app * Made the import app utility return an app instance * Adding a failing anonymous credentials test * Attempt at running integration tests on CI * Switched to lerna when installing environments and tests * Updating some NPM scripts * Fixing root package-lock.json * Removed unneeded complexity in RN test app. * Ignoring scripts when installing locally * Upgraded typescript and package-locks * Removed the regular dependency on realm and tests again * Revert "Removed unneeded complexity in RN test app." This reverts commit 16e04eb. * Fixed running ios tests via a --prefix * Updated the README * Run linting on sub-packages explicitly * Scoping bootstrapping in GH workflow * Propagating context as environments * Adding skipIf to suites * Running local only integration tests on CI * Using lerna bootstrap instead of npm install * Renamed localOnly to missingServer * Moved integration tests to GHA * Running iOS integration tests * Caching xcframework + installing tests package * Inhibiting warnings * Using the mocha-github-actions-reporter * Run in chrome-debugging mode * Upgrading mocha remote * Switch mode from context * Updated script seperator to : * No need to disconnect on end with autoDisconnect * Caching XCode derived data * Caching CocoaPods * Include the CONTEXT environment variable in NPM script * Try running just the Chrome Debugging * Adding cache on Podfile.lcok * Installing watchman * Updated .lock pattern * Adding start.js to pass arguments to mocha * Debugging metro cache invalidation * Adding an option to run chrome debugger headless * Printing module verboseNames * Logging stack on error * Try / catching more. * Cache the ios build folder * Iterating on printing error stacks * Removed caching ios build artifacts again * Logging a stack when a message is logged * Caching node_modules * Try messing less with the RN cache * Retrying cache of the ios build folder * Debugging the tests * Adding a tmate session for debugging * Trying to catch error loading "realm" * Debugging requiring "realm" * Reworded the install script override * Removed peer dependencies on "realm" and the tests * Bumping the ios-build cache version * No need for a mocha peer dependency * Re-introducing the tests * Propagate the error through * Adding build:watch script to tests * Try running tests on Android emulator * Building and running tests for android * Run on Electron as well * Reexporting ANDROID_NDK_HOME * Using xvfb-run * Simplified electron harness * Trying Android test again * Trying a node matrix * Update pr-integration-tests.yml * Adding windows to the Node.js builds * Adding steps to setup windows build env * Use prebuilds for node and run in release and debug mode * Adding runtime and target to package.json's config * Upgraded mocha-remote-cli * Retry opening the Metro Chrome debugging UI * Run React Native in both release & debug * Fixed RN Android job name * Renamed flow file and name * Upgrading mocha-remote * Upgrading CocoaPods and Flipper-Folly * Calling logcat before exiting on Android * Updated README.md files * Adding a Realm.Set when chrome debugging (#3704) * Enable streaming logcat while testing * Clarified some documentation * Minor clean ups * Xcode updated some project files * Attempting to apply a fix to breaking ios builds * Simplified skipIf * Moved the local_prebuilds env * Reusing a variable * Disabled chrome debugging tests for now * Update CHANGELOG.md * Apply suggestions from code review Co-authored-by: Andrew Meyer <[email protected]> Co-authored-by: Andrew Meyer <[email protected]> * Fixing Issue #3731 (#3735) * Fixing Issue #3731 * Adding entry to the changelog * Fix dictionary error message (#3728) * Removing dead code * Adding validation and error message, when the user tries to delete a key that doesn't exist. * Adding validation and error message, when the user tries to delete a key that doesn't exist. [JSC] * Refactoring and testing JSC error handling for methods * Improving the test for key removal * Adding changelog Co-authored-by: Cesar Valdez <[email protected]> * Fix Electron for Windows (#3737) There is an issue where Windows incorrectly binds the DLL. This fix corrects this. * Integration tests of `mixed` values (#3732) * Fixed the realm-app-importer * Added more configuration to the realm apps * Added a reusable hook to import an app before test * Adding scaffolding for a sync mixed test * Adding three Mocha hooks to simplify testing * Adding a Mixed type to the TS declaration * Adding sync tests of mixed values * Fixing the other tests * Skipping mixed tests when missiong a server * Simplified the tests a bit * Moved the skipIf a level up * Upgrade to Realm Core v11.0.0-beta.5 (#3753) * Upgrade to Realm Core v11.0.0-beta.5 * Ff/develop/generate doxygen (#3769) Added npm script to generate Doxygen documentation for internal API * Upgrade to Realm Core v11.0.0-beta.6 [TAKE THREE] (#3779) * Upgrade to Realm Core v11.0.0-beta.6 * Remove Realm._objectForObjectId() * Make vcpkg path configurable via an environment variable (#3777) * Enable setting path of vcpkg via environment * Update CMakeLists.txt * Update CMakeLists.txt Co-authored-by: Yavor Georgiev <[email protected]> Co-authored-by: Yavor Georgiev <[email protected]> * Omit zlib on windows (#3787) * Add zlib only when not on windows * Adding a note to the changelog * Update CHANGELOG.md * Upgrade to Realm Core v11.0.3 (#3786) * Upgrade to Realm Core v11.0.3 * Dictionary change listeners are now key based * Use random files names in tests Co-authored-by: FFranck <[email protected]> * New datatypes TS updates (#3749) * Simple Realm.Dictionary interface added (links to non-existing docs) * RealmInsertionModel updated to include Realm.Set * Update typescript types to define Dictionary functions Co-authored-by: Andrew Meyer <[email protected]> * Disable debug tests until builds are optimized. (#3803) * Merge v10.4.2 into develop (#3796) * Improve Dictionary Typescript Types (#3801) Make the Dictionary type more dynamic. There is also a bit of refactoring done for the RealmInsertionModel to make it more readable * Change install script to 'build' instead of 'rebuild' (#3807) Everytime `npm install` is invoked for this project, the entire build is thrown away and built from scratch. The change to `rebuild` will make sure the build artifacts are reused. In the case that the build artifacts are not there, it will build anyway. * Merge master -> develop (#3806) Merge of `master` branch into `develop` in preparation for release of 10.5.0 * Updated dependencies.list * Fix for broken tests in Release Possible that the changing of the set_constructor variable name fixes issues. * Set version to a unpublished one * Force local installs for lerna. This allows release candidates to properly build. * Dictionaries disabled (#3816) * Disabling dictionaries * Pulled out a bit more * Simplified the dictionary type check * [v10.5.0] Bump version * Adding changelog template * Lint fixes for realm-web * Fix merge conflict artifacts * Peg core to 11.0.4 Co-authored-by: Cesar Valdez <[email protected]> Co-authored-by: Cesar Valdez <[email protected]> Co-authored-by: Steffen Agger <[email protected]> Co-authored-by: Kenneth Geisshirt <[email protected]> Co-authored-by: Andrew Meyer <[email protected]> Co-authored-by: Mathias Stearn <[email protected]> Co-authored-by: Kenneth Geisshirt <[email protected]> Co-authored-by: Cesar Valdez <[email protected]> Co-authored-by: Nikola Irinchev <[email protected]> Co-authored-by: cesar <[email protected]> Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Yavor Georgiev <[email protected]> Co-authored-by: Kenneth Geisshirt <[email protected]>
What, How & Why?
This PR implements support for Realm's new Set datatype on JS.
This PR closes #3460, #3386, #3384, #3378.
Partially addressed:
☑️ ToDos
* [ ] 📝Compatibility
label is updated or copied from previous entry* [ ] 💥Breaking
label has been applied or is not necessaryIf this PR adds or changes public API's: