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

working on json_path_exists #4286

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

Conversation

valkrypton
Copy link
Contributor

@weiznich I was trying to implement the jsonb_path_exists function. One of its argument is of type Jsonpath. Currently there is no such type in diesel, so I tried to implement it using the jsonpath_rust crate.

I implemented the FromSql trait for it, but I could not figure out how to implement the ToSql trait. I'd appreciate if you could take a look and help me with this or maybe i am going completely in the wrong direction with this?

@weiznich
Copy link
Member

weiznich commented Oct 2, 2024

Thanks for working on this. The FromSql implementation needs to read the binary representation of a json path as defined in the PostgreSQL protocol. Unfortunately the documentation of that format is mostly not existing, at least for anything that's not a trivial type. That means you likely need to perform some experimentation. One possibility would be to just setup a test case that loads a jsonpath value from the database and inspect the output. That should tell us how postgres serializes these data. Hopefully that's just the path as string or something simple like that. The other way is to dig through the postgres source code and find something there. This file might be a starting point.

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.

2 participants