-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add the capability of createIndex to take index expression in N1QL (i… #1175
Conversation
…n addition to JSON). #CBL-1939
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.
We need some more tests, too --
- of regular value indexes
- of using the C API.
@@ -242,7 +261,7 @@ static C4SliceResult getIndexes(C4Database* database, bool fullInfo, C4Error* ou | |||
enc.beginDictionary(); | |||
enc.writeKey("name"); enc.writeString(spec.name); | |||
enc.writeKey("type"); enc.writeInt(spec.type); | |||
enc.writeKey("expr"); enc.writeString(spec.expressionJSON); | |||
enc.writeKey("expr"); enc.writeString(spec.expression); |
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'd be easy to add a language
key with the language, so let's do that.
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.
Do I write an enum (integer) or string, "n1ql" or "json" ?
LiteCore/Query/IndexSpec.cc
Outdated
_doc = Doc::fromJSON(expressionJSON); | ||
} catch (const FleeceException &) { | ||
error::_throw(error::InvalidQuery, "Invalid JSON in index expression"); | ||
if (queryLanguage == QueryLanguage::kJSON) { |
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 cleaner as a switch
. Leave out the default:
label, so the compiler will warn if any extra enum value is added in the future.
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.
Okay, will do it.
LiteCore/Storage/KeyStore.cc
Outdated
slice expressionJSON, | ||
IndexSpec::Type type, | ||
const IndexSpec::Options* options) | ||
bool KeyStore::createIndex2(slice name, |
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 I'd prefer this be named just createIndex
, since C++ allows overloading.
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.
Same for me! This method already has some default parameters, the query language could be another so it doesn't even have to be overloaded if you add it at the end. Overloading works too though.
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.
Changed accordingly.
LiteCore/Storage/KeyStore.cc
Outdated
slice expressionJSON, | ||
IndexSpec::Type type, | ||
const IndexSpec::Options* options) | ||
bool KeyStore::createIndex2(slice name, |
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.
Same for me! This method already has some default parameters, the query language could be another so it doesn't even have to be overloaded if you add it at the end. Overloading works too though.
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 don't have additional comments.
…n addition to JSON). #CBL-1939