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

Add missing sqlite json/jsonb functions and operators #4366

Open
3 of 33 tasks
weiznich opened this issue Nov 27, 2024 · 4 comments
Open
3 of 33 tasks

Add missing sqlite json/jsonb functions and operators #4366

weiznich opened this issue Nov 27, 2024 · 4 comments

Comments

@weiznich
Copy link
Member

weiznich commented Nov 27, 2024

Diesel currently supports the sqlite json/jsonb types. We do not provide built-in support for various methods available for these types. This is a tracking issue for adding support for these methods.

The general strategy for adding support for new methods is as following:

  1. Define the function via define_sql_function!(). These functions can be defined here in a new functions.rs module. See the linked definition of to_json for an example from the postgres backend as an example. This function should have a short documentation snippet with an example (See the linked sqlite documentation for examples for all of the function, please also add variants with null values, etc). If there is a json and a jsonb variant, please implement both in a single PR.
  2. If the function is generic, add a helper type definition here. Again see the linked definition for an example for the to_json function from the postgres backend for an example.
  3. Add a test for #[auto_type] support for the newly added function here
  4. Submit a PR with the change

Method list:

There are four aggregate SQL functions:

For items marked with * the instructions above can be followed as written down

Items marked with ** are variadic functions on SQL side. Rust does not support such function definitions yet, so we either need to have variants for a certain number of fixed arguments or we need to find another solution.

For items marked with *** the function definition needs to be marked with the #[aggregate] attribute.

Operators:

For operators:

These already exists for the postgres backend here. We need to look for a way to share these impls.

@xuehaonan27
Copy link
Contributor

xuehaonan27 commented Nov 27, 2024

I would like to take json(json) and jsonb(json)

Edit on Dec 12 2024: pull request for this #4388

Edit on Dec 12 2024: update libsqlite3-sys feature bundled-bindings to bundled on the PR branch.

Edit on Dec 13 2024: using libsqlite3-sys bundled-bindings and changed json/jsonb definitions.

@KekmaTime
Copy link

I will work on json_valid(json) & json_type(json)

@xuehaonan27
Copy link
Contributor

May I work on more tasks?

@weiznich
Copy link
Member Author

@xuehaonan27 Sure that would be very welcome

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

No branches or pull requests

3 participants