-
Notifications
You must be signed in to change notification settings - Fork 75
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
CBL-6671: Options of FTS partial index is not fully encoded in the SQ… #2220
Conversation
Code Coverage Results:
|
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 couple minor comments. Apart from that, look good to me.
else if ( whereA ) | ||
same = whereA->toJSONString() == whereB->toJSONString(); | ||
} | ||
} |
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.
Maybe a bit cleaner if move this to kFullText case itself.
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.
You can compare Values more simply than this:
same = v1 ? v1->isEqual(v2) : !v2;
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.
This is intentional. I think the logic applies both to Vector and FTS, only at this time, I don't want to touch Vector
if ( spec.type == IndexSpec::kFullText ) { | ||
if ( same ) { | ||
auto whatA = spec.what(), whatB = existingSpec->what(); | ||
if ( !whatA ? whatB != nullptr : !whatB ) same = false; |
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.
Could what be practically NULL? I understand that it's a required field.
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 the purpose here is to check the sameness. NULL should be avoided somewhere else.
I tried it, empty expression will cause crash before coming to here.
Do platforms check it?
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.
If LiteCore returns the error for the empty expression, the platform will return or throw an exception to the user for that error.
@@ -112,15 +112,19 @@ namespace litecore { | |||
/** The optional WHERE clause: the condition for a partial index */ | |||
const fleece::impl::Array* where() const; | |||
|
|||
void setWhereClause(string_view whereClause_) const { | |||
if ( !whereClause_.empty() ) whereClause = alloc_slice::nullPaddedString(whereClause_); |
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.
Doing nothing when the string is empty could cause bugs later on, if someone wants to clear an existing where clause by calling this. Safer to set whereClause
to nullslice
in that case.
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 see. I intend it to be constant, not to be changed after first assigned.. How about throw if current value is not null? Maybe throw is too rough, but most likely the second assignment is not right. Maybe I can add a warning.
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.
@snej I like it to be almost const, not to be changed after the first assignment. What do you prefer in following?
A. throw if assigned value second time
B. log an warning
C. don't try to limit it
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.
It shouldn't be a const
method: it changes the visible state of the object.
…Lite table when it is registered 1. Bumped Schema version. 2. In the new version, added a column, whereClause, to table indexes. 3. Upgrade the tables in previous version to include the new column 4. IndexSpec::whereClause is registered in table "indexes" by the new column. 5. c4index_getOptions will have "where" passed in with C4IndexOptions. 6. Tests of the above.
@@ -112,15 +112,19 @@ namespace litecore { | |||
/** The optional WHERE clause: the condition for a partial index */ | |||
const fleece::impl::Array* where() const; | |||
|
|||
void setWhereClause(string_view whereClause_) const { | |||
if ( !whereClause_.empty() ) whereClause = alloc_slice::nullPaddedString(whereClause_); |
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.
It shouldn't be a const
method: it changes the visible state of the object.
LiteCore/Query/IndexSpec.hh
Outdated
std::string const name; ///< Name of index | ||
Type const type; ///< Type of index | ||
alloc_slice const expression; ///< The query expression | ||
mutable alloc_slice whereClause; ///< The where clause. If given, expression should be the what clause |
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.
Should not be mutable
CBL-6671: Options of FTS partial index is not fully encoded in the SQ… (#2220) CBL-6534: Fix expiration column upgrade (#2195) (#2219) CBL-6626: SQL++ query not return expected results (#2209) CBL-6667: Remove LIMIT restriction in vector search (#2217) CBL-6670: Code coverage script failing on arm64 (#2218) CBL-6576: Implement Partial Index LiteCore API (#2215) CBL-6651: createIndex doesn't support creating partial index with N1Q… (#2214) CBL-6371: Unnest Query run after delete index produces obtuse error message (#2178) CBL-6625: SQL++ query throws error unexpectedly (#2201)
Includes these tickets in release/3.2: CBL-6671: Options of FTS partial index is not fully encoded in the SQ… (#2220) CBL-6534: Fix expiration column upgrade (#2195) (#2219) CBL-6626: SQL++ query not return expected results (#2209) CBL-6667: Remove LIMIT restriction in vector search (#2217) CBL-6670: Code coverage script failing on arm64 (#2218) CBL-6576: Implement Partial Index LiteCore API (#2215) CBL-6651: createIndex doesn't support creating partial index with N1Q… (#2214) CBL-6371: Unnest Query run after delete index produces obtuse error message (#2178) CBL-6625: SQL++ query throws error unexpectedly (#2201)
Includes these tickets in release/3.2: CBL-6671: Options of FTS partial index is not fully encoded in the SQ… (#2220) CBL-6534: Fix expiration column upgrade (#2195) (#2219) CBL-6626: SQL++ query not return expected results (#2209) CBL-6667: Remove LIMIT restriction in vector search (#2217) CBL-6670: Code coverage script failing on arm64 (#2218) CBL-6576: Implement Partial Index LiteCore API (#2215) CBL-6651: createIndex doesn't support creating partial index with N1Q… (#2214) CBL-6371: Unnest Query run after delete index produces obtuse error message (#2178) CBL-6625: SQL++ query throws error unexpectedly (#2201) * Update XCode project version to 3.2.2 (#2198) * CBL-6625: SQL++ query throws error unexpectedly (#2201) * CBD-6163: BSL License updates - Couchbase Lite Version 3.2 (#2207) Change-Id: Ibc0efec8cff9eea29d1fbbfb087e931f92e09fa1 * CBL-6371: Unnest Query run after delete index produces obtuse error message (#2178) We enhanced the error by adding to the original message, "This table is referenced by an array index, which may have been deleted." * We also enhanced the error message of FTS index in the similar situation. * CBL-6651: createIndex doesn't support creating partial index with N1Q… (#2214) * CBL-6651: createIndex doesn't support creating partial index with N1QL language Extended IndexSpec to allow the where clause when the query langugage is N1QL. We put it in IndexSpec::options. In this commit, we only do it for ValueIndex and FTSIndex. With JSON query language, the where clause can be either in the new option or in IndexSpec::expression together with the what clause. With N1QL query language, the where clause has to be in the field of IndexSpec, and IndexSpec::expression contains only the what clause. This commit is to get ready for C4IndexOptions * CBL-6576: Implement Partial Index LiteCore API (#2215) Added field "where" to C4IndexOptions and implemented it. * CBL-6670: Code coverage script failing on arm64 (#2218) * CBL-6667: Remove LIMIT restriction in vector search (#2217) The removal of restriction of "LIMIT > 0" matches that in 4.0 line. * CBL-6626: SQL++ query not return expected results (#2209) * CBL-6534: Fix expiration column upgrade (#2195) (#2219) * CBL-6534: Fix expiration column upgrade (#2195) Co-authored-by: jianminzhao <[email protected]> * CBL-6671: Options of FTS partial index is not fully encoded in the SQ… (#2220) * CBL-6671: Options of FTS partial index is not fully encoded in the SQLite table when it is registered 1. Bumped Schema version. 2. In the new version, added a column, whereClause, to table indexes. 3. Upgrade the tables in previous version to include the new column 4. IndexSpec::whereClause is registered in table "indexes" by the new column. 5. c4index_getOptions will have "where" passed in with C4IndexOptions. 6. Tests of the above. --------- Co-authored-by: Vlad Velicu <[email protected]> Co-authored-by: callumbirks <[email protected]> Co-authored-by: Couchbase Robot <[email protected]>
…Lite table when it is registered