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

SQLITE_ENABLE_JSON1 flag does not appear to compile sqlite3 with this option #425

Closed
jcurtis-cc opened this issue May 29, 2023 · 7 comments
Assignees
Labels

Comments

@jcurtis-cc
Copy link

jcurtis-cc commented May 29, 2023

SQLiteCpp with the SQLITE_ENABLE_JSON1 #289 doesn't appear to be working. I'm using the following query to test, which returns zero.

SELECT sqlite_compileoption_used('ENABLE_JSON1')

I changed the line in ./build.sh to

cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITE_ENABLE_JSON1=ON -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..

And created a quick test in Database_test.cpp - which fails. for ease, you can pull it from my fork here

#ifdef SQLITE_ENABLE_JSON1
TEST(Database, json1)
{
    remove("test.db3");
    {
        // Create a new database
        SQLite::Database db("test.db3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
        EXPECT_FALSE(db.tableExists("test"));
        EXPECT_EQ(1, db.exec("SELECT sqlite_compileoption_used('ENABLE_JSON1')"));
    } // Close DB test.db3
    remove("test.db3");
}
#endif // SQLITE_ENABLE_JSON1

Any thoughts? Perhaps I'm missing something obvious here.

@SRombauts SRombauts self-assigned this May 29, 2023
@SRombauts
Copy link
Owner

Hello, can you provide more details on your setup? What OS? Aka is your project really recompiling the sqlite library or using an existing one from your distribution?

I am not in front of a computer so I cannot check the feature (coming from PR #288)

@jcurtis-cc
Copy link
Author

Sure, MacOS 12.16 here

@SRombauts
Copy link
Owner

I think that's the reason, by default on Unixes CMake will detect the existing sqlite3 dynamic library installed in your system and use it
You want to use the cmake flag to force using the internal library built from source code

@SRombauts
Copy link
Owner

I know documentation is far from perfect, from the readme on troubleshooting:

or turn on the option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON) in CMakeFiles.txt

Let me know if you have any trouble with that

@jcurtis-cc
Copy link
Author

option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON))

looks to be on by default this is also mentioned again here

perhaps something here is overriding this:

cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITE_ENABLE_JSON1=ON -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..

SRombauts added a commit that referenced this issue May 31, 2023
since the JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22).

see issue #425 SQLITE_ENABLE_JSON1 flag does not appear to compile sqlite3 with this option
@SRombauts
Copy link
Owner

See PR #428 for the new branch I just pushed:
Remove option SQLITE_ENABLE_JSON1 since the JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22).

For us with SQLiteCpp it would be since Version 3.2.0 - 2022 September 18

@SRombauts
Copy link
Owner

I hope this helps
Cheers!

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

No branches or pull requests

2 participants