Skip to content
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

Implement missing JSON operators #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ycanardeau
Copy link

This PR implements the <@, ?, ?| and ?& JSON operators. Some of the test cases were taken from https://www.postgresql.org/docs/15/functions-json.html.

Copy link
Owner

@oguimbal oguimbal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ! Thanks for the PR.

I believe you have missed use cases ... for instance when json arguments are numbers, or null.

i.e. not the postgres NULL (in which case the function will not be called, because it does not state that it supports null arguments), but the json 'null'::jsonb kind of null (which is different, and will effectively pass a null argument to the function).

FYI, here is the ? implementation as I am using it in one of my projects:

  implementation: (a, b) => Array.isArray(a) ? a.includes(b) : typeof a === 'object' && b && a && b in a;

Not sure if it is exactly accurate, but I believe it behaves as expected when a is null 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants