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 support for JSON #42

Closed
sunshine69 opened this issue Sep 14, 2021 · 8 comments
Closed

Add support for JSON #42

sunshine69 opened this issue Sep 14, 2021 · 8 comments

Comments

@sunshine69
Copy link

Hi,

It seems out of the box the extenstion is not supported. I did try to use json1 and got error like function json_extract does not exists.

How can I build the library with json1 ext support for example?

Thanks

@sunshine69
Copy link
Author

sunshine69 commented Sep 14, 2021

To be explicit, the normal build seems to have the extenstion compiled but not for the static musl target

cargo build --release --target x86_64-unknown-linux-musl

this command build my test repo and produce a non supported json extention.

while the default on ubuntu 20.04 works fine.

so the question really is how to build statically built with json1 ext support for that target x86_64-unknown-linux-musl

@sunshine69
Copy link
Author

For what is it worth the other (more popular one https://github.com/rusqlite/rusqlite) does not have the problem with the musl target. However I like this more as it has some easier way for me to dynamically find the col names and types.

I would think there is a compile option somewhere which enables the build generically?

@IvanUkhov
Copy link
Member

Thank you for the issue! If you know how to compile the original source so it has the support you need, it is a matter of updating this logic:

https://github.com/stainless-steel/sqlite3-src/blob/master/build.rs

Currently, it is simple, but we can add features.

@sunshine69
Copy link
Author

No I am quite new to rust so still finding way around. All I do is using cargo run and cargo build command like above. I would like to be able to build statically linked.

Look at the other repo they have something like this in Cargo.toml file

[dependencies.rusqlite]
version = "0.25.3"
features = ["bundled"]

Can we design the similar way to add a features option and enforce it to compile for all target? I don't know how though, if I know I would create a PR :)

@IvanUkhov
Copy link
Member

IvanUkhov commented Sep 14, 2021

Please take a look at what the documentation says about extension support:

https://sqlite.org/howtocompile.html

Maybe the problem is in what other libraries are available when compiling and the corresponding directives. Most likely, -DSQLITE_ENABLE_JSON1 has to be added with an appropriate -l in build.rs.

@IvanUkhov IvanUkhov changed the title sqlite3 extenstion support Enable extensions Oct 22, 2022
@IvanUkhov IvanUkhov changed the title Enable extensions Add support for extensions Oct 22, 2022
@jonatansalemes
Copy link

#75 add support do developer enable/disable and load extensions.

@IvanUkhov
Copy link
Member

I think we are talking about two different types of extensions here. There are those that are built in, such as JSON, and there are those that are not. PR #75 is about the latter and unlikely to help with this issue if I understand correctly.

The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22). They can be omitted by adding the -DSQLITE_OMIT_JSON compile-time option. Prior to version 3.38.0, the JSON functions were an extension that would only be included in builds if the -DSQLITE_ENABLE_JSON1 compile-time option was included. In other words, the JSON functions went from being opt-in with SQLite version 3.37.2 and earlier to opt-out with SQLite version 3.38.0 and later.

@IvanUkhov IvanUkhov changed the title Add support for extensions Add support for JSON Oct 6, 2023
@IvanUkhov
Copy link
Member

Closing as per the above quote.

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

No branches or pull requests

3 participants