-
Notifications
You must be signed in to change notification settings - Fork 0
Implement $exists #17
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
Conversation
bbadf91
to
a827073
Compare
isNestedColumn := c.nestedColumn != "" | ||
for _, exemption := range c.nestedExemptions { | ||
if exemption == key { | ||
isNestedColumn = false | ||
break | ||
} | ||
} |
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 code is duplicated in the case nil:
as well, we could lift it above the switch.
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.
Yeah we can change those once the two pulls are both merged.
} | ||
if !isNestedColumn { | ||
// There is no way in Postgres to check if a column exists on a table. | ||
return "", nil, fmt.Errorf("$exists operator not supported on non-nested jsonb columns") |
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.
Alternatively we can always return TRUE if it's not a nested column (or this could be an option).
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.
But that's not true. The column can also not exist. The only way to actually check is selecting from information_schema.columns
which seems dangerous and not possible since we don't know the table 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.
That's right, good point. 👍
See: https://www.mongodb.com/docs/manual/reference/operator/query/exists/