libsql / sqld

LibSQL with extended capabilities like HTTP protocol, replication, and more.
https://libsql.org
900 stars 38 forks source link

Enable SQLite JSON Extension #346

Closed penberg closed 1 year ago

penberg commented 1 year ago

We had someone ask for the JSON1 extensions. However, they are already integrated to SQLite: https://wiki.tcl-lang.org/page/SQLite+extension+JSON1, but don't work:

→  json_object('ex','[52,3.14159]');
Error: Failed to execute SQL statement: json_object('ex','[52,3.14159]');
syntax error around L1:12: `json_object`

Are they tripping over sqld parser?

psarna commented 1 year ago

That sounds like an sqlite error. Let's enable rusqlite https://github.com/rusqlite/rusqlite/blob/051dcf673defa03033f6ef81c4c21bfe6f2a26be/Cargo.toml#L85 feature for starters, it will enable the built-in extensions

psarna commented 1 year ago

@penberg I just checked on my local sqld and my turso machine, and both ran just fine:

→  select json_object("name", "Igor", "age", 33);
JSON_OBJECT ("NAME", "IGOR", "AGE", 33)  
{"name":"Igor","age":33}

I think the issue here is just that somebody tried to call json_object('ex','[52,3.14159]'); instead of SELECT json_object('ex','[52,3.14159]');

Closing the issue as not applicable to fix, already works :shrug: