From 60723269ec28f3882324477c18f03301731e3e38 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 01:25:53 -0700 Subject: [PATCH 1/6] Allow key paths to start with "not" in queries Fixes #445 --- src/object-store/src/parser/parser.cpp | 8 +++++--- src/object-store/tests/parser.cpp | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/object-store/src/parser/parser.cpp b/src/object-store/src/parser/parser.cpp index 6b981b3e..88f2a9f0 100644 --- a/src/object-store/src/parser/parser.cpp +++ b/src/object-store/src/parser/parser.cpp @@ -24,6 +24,8 @@ #include #include +#define string_operator_t(s) seq< pegtl_istring_t(s), not_at< identifier_other > > + using namespace pegtl; namespace realm { @@ -93,11 +95,11 @@ struct group_pred : if_must< one< '(' >, pad< pred, blank >, one< ')' > > {}; struct true_pred : pegtl_istring_t("truepredicate") {}; struct false_pred : pegtl_istring_t("falsepredicate") {}; -struct not_pre : seq< sor< one< '!' >, pegtl_istring_t("not") > > {}; +struct not_pre : seq< sor< one< '!' >, string_operator_t("not") > > {}; struct atom_pred : seq< opt< not_pre >, pad< sor< group_pred, true_pred, false_pred, comparison_pred >, blank > > {}; -struct and_op : pad< sor< two< '&' >, pegtl_istring_t("and") >, blank > {}; -struct or_op : pad< sor< two< '|' >, pegtl_istring_t("or") >, blank > {}; +struct and_op : pad< sor< two< '&' >, string_operator_t("and") >, blank > {}; +struct or_op : pad< sor< two< '|' >, string_operator_t("or") >, blank > {}; struct or_ext : if_must< or_op, pred > {}; struct and_ext : if_must< and_op, pred > {}; diff --git a/src/object-store/tests/parser.cpp b/src/object-store/tests/parser.cpp index 93d5f159..6062928e 100644 --- a/src/object-store/tests/parser.cpp +++ b/src/object-store/tests/parser.cpp @@ -66,6 +66,9 @@ static std::vector valid_queries = { "!(0=0)", "! (0=0)", "NOT0=0", // keypath NOT0 + "NOT0.a=0", // keypath NOT0 + "NOT0a.b=0", // keypath NOT0a + "not-1=1", "not 0=0", "NOT(0=0)", "not (0=0)", @@ -121,6 +124,7 @@ static std::vector invalid_queries = { "(0=0))", "! =0", "NOTNOT(0=0)", + "not.a=0", "(!!0=0)", "0=0 !", @@ -130,7 +134,7 @@ static std::vector invalid_queries = { "a==a &| a==a", "a==a && OR a==a", "a==aORa==a", - //"a=1ANDNOT b=2", + "a=1ANDNOT b=2", "truepredicate &&", "truepredicate & truepredicate", From 87878b8b9c2962ad1aa8cbf2d4fc98b9de625ee3 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 12:40:16 -0700 Subject: [PATCH 2/6] Update CHANGELOG with parser fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e83b8ffe..b59283c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Fix a memory leak caused by constructing a Realm instance of an already opened Realm. * Fix for better supporting hot module reloading. * Fix for some warnings when using `ListView` with React Native 0.25+ +* Fix for queries that use a keypath starting with "not". 0.12.0 Release notes (2016-5-4) ============================================================= From db7cfc0f5d150753e5ed554047a184ae17bed27a Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 13:08:39 -0700 Subject: [PATCH 3/6] Add a few more parser tests --- src/object-store/tests/parser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/object-store/tests/parser.cpp b/src/object-store/tests/parser.cpp index 6062928e..15c5cf2c 100644 --- a/src/object-store/tests/parser.cpp +++ b/src/object-store/tests/parser.cpp @@ -134,6 +134,9 @@ static std::vector invalid_queries = { "a==a &| a==a", "a==a && OR a==a", "a==aORa==a", + "a==a ORa==a", + "a==a AND==a", + "a==a ANDa==a", "a=1ANDNOT b=2", "truepredicate &&", From cfc96995b4d362fa43d5525acb82593621ec4627 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 13:12:40 -0700 Subject: [PATCH 4/6] Include comment about string_operator_t --- src/object-store/src/parser/parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/object-store/src/parser/parser.cpp b/src/object-store/src/parser/parser.cpp index 88f2a9f0..07b97bb4 100644 --- a/src/object-store/src/parser/parser.cpp +++ b/src/object-store/src/parser/parser.cpp @@ -24,6 +24,7 @@ #include #include +// String operators (e.g. AND, OR, NOT) can't be followed by [A-z0-9_]. #define string_operator_t(s) seq< pegtl_istring_t(s), not_at< identifier_other > > using namespace pegtl; From bd863f75908809d3aa62938125a407f0bc6c6f67 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 13:33:00 -0700 Subject: [PATCH 5/6] Remove qualification about date precision in API docs --- docs/realm.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/realm.js b/docs/realm.js index 4d4e2213..ade8d8a8 100644 --- a/docs/realm.js +++ b/docs/realm.js @@ -233,8 +233,7 @@ Realm.defaultPath; * @property {number} "double" - Property may be assigned any number, and will have no loss * of precision. * @property {string} "string" - Property value may be any arbitrary string. - * @property {Date} "date" - Property may be assigned any `Date` instance, but will be stored - * with second-level precision (a fix for this is in progress). + * @property {Date} "date" - Property may be assigned any `Date` instance. * @property {ArrayBuffer} "data" - Property may either be assigned an `ArrayBuffer` * or `ArrayBufferView` (e.g. `DataView`, `Int8Array`, `Float32Array`, etc.) instance, * but will always be returned as an `ArrayBuffer`. From 64ae03512a57a34032552846e39b4460329e0b57 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 19 May 2016 13:33:50 -0700 Subject: [PATCH 6/6] [0.13.0] Bump version --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b59283c2..9ad2ccc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -0.13.0 Release notes (2016-5-16) +0.13.0 Release notes (2016-5-19) ============================================================= ### Breaking changes * With this release we have switched over to a new cross platform compatible date format. diff --git a/package.json b/package.json index ed52b6b3..22944d6a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "0.13.0-rc", + "version": "0.13.0", "license": "Apache-2.0", "homepage": "https://realm.io", "keywords": [