From f45ba1c9e7608dfb65067e03196079726821b233 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 12 Sep 2018 15:01:44 +0200 Subject: [PATCH] LIMIT support in queries (#2008) * Updating to Realm Sync 3.9.9 (and Core 5.10.0 + object store). * Adding LIMIT to tests * Use bitnami node image --- CHANGELOG.md | 7 +++---- Jenkinsfile | 3 ++- dependencies.list | 4 ++-- docs/tutorials/query-language.md | 15 ++++++++++++--- src/object-store | 2 +- target_defaults.gypi | 3 +++ tests/js/query-tests.json | 4 ++++ 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ab3dd0..35bf1017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,6 @@ X.Y.Z Release notes ============================================================= ### Compatibility -* Sync protocol: 24 -* Server-side history format: 4 * File format: 7 * Realm Object Server: 3.0.0 or later @@ -13,6 +11,7 @@ X.Y.Z Release notes * Exposed `User.serialize` to create a persistable representation of a user instance, as well as `User.deserialize` to later inflate a `User` instance that can be used to connect to Realm Object Server and open synchronized Realms (#1276). +* Added support for `LIMIT` in queries to restrict the size of the results set. This is in particular useful for query-based synced Realms. An example of the syntax is `age >= 20 LIMIT(2)`. ### Bug fixes * Removed a false negative warning when using `User.createConfiguration`. @@ -21,8 +20,8 @@ Server and open synchronized Realms (#1276). * Fixed the type definitions for `Session.addConnectionNotification` and `Session.removeConnectionNotification` ### Internal -* Realm Core v5.7.2. -* Realm Sync v3.9.1. +* Upgraded to Realm Core v5.10.0. +* Upgraded to Realm Sync v3.9.9. 2.15.3 Release notes (2018-8-24) ============================================================= diff --git a/Jenkinsfile b/Jenkinsfile index 1e8c522c..a0075ad3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -181,7 +181,8 @@ def doDockerBuild(target, postStep = null) { try { reportStatus(target, 'PENDING', 'Build has started') - docker.image('node:6').inside('-e HOME=/tmp') { + // We use the bitnami/node image since it comes with GCC 6.3 + docker.image('bitnami/node:6').inside('-e HOME=/tmp') { sh "scripts/test.sh ${target}" if(postStep) { postStep.call() diff --git a/dependencies.list b/dependencies.list index 42464626..193d740c 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js VERSION=2.15.3 -REALM_CORE_VERSION=5.7.2 -REALM_SYNC_VERSION=3.9.1 +REALM_CORE_VERSION=5.10.0 +REALM_SYNC_VERSION=3.9.9 REALM_OBJECT_SERVER_VERSION=3.0.0 diff --git a/docs/tutorials/query-language.md b/docs/tutorials/query-language.md index 5d050591..f399b0fe 100644 --- a/docs/tutorials/query-language.md +++ b/docs/tutorials/query-language.md @@ -1,4 +1,4 @@ -The Realm JavaScript SDK supports querying based on a language inspired by [NSPredicate](https://realm.io/news/nspredicate-cheatsheet/). +The Realm JavaScript SDK supports querying based on a language inspired by [NSPredicate](https://realm.io/news/nspredicate-cheatsheet/). The {@link Realm.Collection#filtered Collection.filtered()} method is used to query a Realm: @@ -24,8 +24,8 @@ let merlots = wines.filtered('variety == $0 && vintage <= $1', 'Merlot', maxYear ### Conditional operators -You can use equality comparison on all property types: -`==` and `!=` +You can use equality comparison on all property types: +`==` and `!=` Furthermore, the following can be used on numerical types: `<`, `<=`, `>`, `>=` @@ -75,6 +75,15 @@ realm.objects('Person').filtered('birthday == T1435846997:233') // equivalent to realm.objects('Person').filtered('birthday == 1970-1-1@0:0:0:0') // epoch is the default non-null Timestamp value ``` +### Limiting the size of the result set +In order to limit the number of objects in a result set, you can use `LIMIT`. + +Example: + +```JS +realm.objects('Person').filtered('age >= 20 LIMIT(2)') // at most two objects which fulfil the condition +``` + ### Queries on collections When objects contain lists you can query into them using the collection operators `ANY`, `ALL` and `NONE`. diff --git a/src/object-store b/src/object-store index 97fd0381..b0fc2814 160000 --- a/src/object-store +++ b/src/object-store @@ -1 +1 @@ -Subproject commit 97fd03819f398b3c81c8b007feaca8636629050b +Subproject commit b0fc2814d9e6061ce5ba1da887aab6cfba4755ca diff --git a/target_defaults.gypi b/target_defaults.gypi index e6e629ca..74ea68d1 100644 --- a/target_defaults.gypi +++ b/target_defaults.gypi @@ -37,6 +37,9 @@ "OTHER_LDFLAGS": ["-framework Foundation"], "WARNING_CFLAGS": [ "<@(warning-flags)" ] } + }], + ["OS=='linux'", { + "defines": [ "_GLIBCXX_USE_CXX11_ABI=0" ] }] ], # windows stuff diff --git a/tests/js/query-tests.json b/tests/js/query-tests.json index 678e0f5b..2cff1f27 100644 --- a/tests/js/query-tests.json +++ b/tests/js/query-tests.json @@ -81,6 +81,7 @@ ["QueryCount", 3, "IntObject", "intCol <= 100"], ["QueryCount", 1, "IntObject", "intCol > 0x1F"], ["QueryCount", 1, "IntObject", "intCol == $0", 100], + ["QueryCount", 2, "IntObject", "intCol >= 0 LIMIT(2)"], ["QueryThrows", "IntObject", "intCol == 'not an int'"], ["QueryThrows", "IntObject", "intCol == true"], @@ -112,6 +113,7 @@ ["QueryCount", 3, "FloatObject", "floatCol <= 100.2"], ["QueryCount", 1, "FloatObject", "floatCol > 0x1F"], ["QueryCount", 1, "FloatObject", "floatCol == $0", 100.2], + ["QueryCount", 2, "FloatObject", "floatCol >= 0.0"], ["QueryThrows", "FloatObject", "floatCol == 'not a float'"], ["QueryThrows", "FloatObject", "floatCol == true"], @@ -146,6 +148,7 @@ ["QueryCount", 3, "DoubleObject", "doubleCol <= 100.2"], ["QueryCount", 1, "DoubleObject", "doubleCol > 0x1F"], ["QueryCount", 1, "DoubleObject", "doubleCol == $0", 100.2], + ["QueryCount", 2, "DoubleObject", "doubleCol >= 0.0 LIMIT(2)"], ["QueryThrows", "DoubleObject", "doubleCol == 'not a double'"], ["QueryThrows", "DoubleObject", "doubleCol == true"], @@ -192,6 +195,7 @@ ["QueryCount", 9, "StringObject", "stringCol CONTAINS ''"], ["QueryCount", 2, "StringObject", "stringCol == $0", "a"], ["QueryCount", 2, "StringObject", "stringCol ENDSWITH $0", "c"], + ["QueryCount", 2, "StringObject", "stringCol BEGINSWITH 'a' LIMIT(2)"], ["QueryThrows", "StringObject", "stringCol == true"], ["QueryThrows", "StringObject", "stringCol == 123"],