-
Notifications
You must be signed in to change notification settings - Fork 164
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
PoC: Add MQL translation skeleton #7123
base: master
Are you sure you want to change the base?
Conversation
3b74cb4
to
36dab22
Compare
Pull Request Test Coverage Report for Build github_pull_request_285284
💛 - Coveralls |
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.
Awesome
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.
Nice work!
A couple suggestions to round things out, but as a prototype, I think it is fine to add this in given that it is an additive change. 👍
case QueryLogicalOperators::$not: | ||
node = m_parse_nodes.create<NotNode>(get_query_node(static_cast<bson::BsonDocument>(value))); | ||
break; | ||
case QueryLogicalOperators::$nor: |
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 probably throw something here if it isn't supported?
src/realm/parser/query_bson.cpp
Outdated
REALM_ASSERT(value.type() == bson::Bson::Type::Array); | ||
std::vector<QueryNode*> nodes = get_query_nodes(static_cast<bson::BsonArray>(value)); | ||
REALM_ASSERT(nodes.size() >= 2); | ||
node = m_parse_nodes.create<AndNode>(nodes[0], nodes[1]); |
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.
LogicalNode::children
is public, so it should be fairly straight forward to append any additional conditions beyond the first two. Same with the handling of "$or" below.
src/realm/parser/query_bson.cpp
Outdated
if (logical_operators.count(key)) { | ||
switch (logical_operators[key]) { | ||
case QueryLogicalOperators::$and: { | ||
REALM_ASSERT(value.type() == bson::Bson::Type::Array); |
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 these types of conditions should be throwing "invalid query" or something similar rather than asserting. But not blocking.
)""""); | ||
CHECK(object_results.size() == 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.
Could you test a few non-happy paths to make sure that a reasonably worded syntax error is thrown?
Suggestions:
{ "non-existing-property": "something" }
{ str_col: { $regex: "(?i)a(?-i)cme" } }
(non-supported query operator "$regex"){ "mal-formed-bson" : }
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.
👍
Let's not merge this yet. |
@jsflax What is going to happen with this PR? |
Unclear right now– we need to road map this before moving forward with the actual feature. However, if this is adding enough additional useful stuff, I'd be fine removing the MQL features from the header and then consider merging the rest. |
@jsflax you mean removing the changes to results.hpp? I am not sure what the risk of keeping it would be. I would prefer that we can keep the test. |
No description provided.