-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Comments
I would like to take Edit on Dec 12 2024: pull request for this #4388 Edit on Dec 12 2024: update Edit on Dec 13 2024: using |
I will work on |
May I work on more tasks? |
@xuehaonan27 Sure that would be very welcome |
I'll work on |
Hey, I took care of |
Hi, I went head and opened a PR on json_error_position |
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:
define_sql_function!()
. These functions can be defined here in a newfunctions.rs
module. See the linked definition ofto_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 ajson
and ajsonb
variant, please implement both in a single PR.to_json
function from the postgres backend for an example.#[auto_type]
support for the newly added function hereMethod list:
json(json)
*jsonb(json)
*json_array(value1, value2, …)
**jsonb_array(value1, value2, …)
**json_array_length(json)
*json_array_length(json, path)
*json_error_position(json)
*json_extract(json, path, …)
**jsonb_extract(json, path, …)
**json_insert(json, path, value, …)
**jsonb_insert(json, path, value, …)
**json_object(label1, value1, …)
**jsonb_object(label1, value1, …)
**json_patch(json1, json2)
*jsonb_patch(json1, json2)
*json_pretty(json)
*json_remove(json, path, …)
**jsonb_remove(json, path, …)
**json_replace(json,path,value,...)
**jsonb_replace(json,path,value,...)
**json_set(json,path,value,...)
**jsonb_set(json,path,value,...)
**json_type(json)
*json_type(json,path)
*json_valid(json)
*json_valid(json,flags)
*json_quote(value)
*There are four aggregate SQL functions:
json_group_array(value)
***jsonb_group_array(value)
***json_group_object(label,value)
***jsonb_group_object(name,value)
***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:
json -> path
json ->>
For operators:
These already exists for the postgres backend here. We need to look for a way to share these impls.
The text was updated successfully, but these errors were encountered: