-
Notifications
You must be signed in to change notification settings - Fork 173
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
Support equal/not_equal on a link column against a Mixed value #4597
Conversation
src/realm/query.cpp
Outdated
ObjLink link = value.get_link(); | ||
auto target_table = table.get_link_target(column_key); | ||
if (target_table->get_key() == link.get_table_key()) { | ||
key = link.get_obj_key(); |
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 the tables don't match, this code will still create matches on null links, but I don't think we want to do that. For mismatching tables, should we also throw the type mismatch error? Or maybe we can allow it but make a FALSEPREDICATE node?
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 changed to return a FalseExpression in case of mismatching tables.
src/realm/query_engine.cpp
Outdated
else if (m_column_type == col_type_Link) { | ||
for (auto& key : m_target_keys) { | ||
if (key) { | ||
// LinkColumn stores link to row N as the integer N + 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.
this comment has become stale and is not relevant to the code anymore, not related to your changes just noticing now
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.
👍
src/realm/query_engine.cpp
Outdated
ObjKey key = m_target_keys[0]; | ||
|
||
if (m_column_type == col_type_LinkList || m_condition_column_key.is_set()) { | ||
if (!key) { |
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.
not sure if the query engine allows this or not, but maybe add an extra check to prevent matching null keys to an empty list
if (!key) { | |
if (!key && start != end) { |
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.
Not sure either. Anyway the early out should be removed. We should not have a match on an empty list.
CHECK_EQUAL(tv.size(), 2); | ||
q = source->where().not_equal(col_linklist, Mixed(target_keys[6])); | ||
tv = q.find_all(); | ||
CHECK_EQUAL(tv.size(), 2); |
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 add some checks for searching for == and != null, across linklist and link? Just making sure we haven't changed behaviour from before.
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.
Well - this is new functionality. We could not do this before. LinksToNode would never match on a null link. Added some more test involving null.
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.
Right, good point. Thanks for adding tests anyhow 😄
676403e
to
da86829
Compare
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.
LGTM 👍
What, How & Why?
Functionality requested by SDKs
☑️ ToDos