I realize it's not the latest version, but I'm having an issue where the
moment I want the sqlite3 extension to do variable interpolation, it will
break json_extract()

See this tclsh output:

% mydb eval "SELECT json_extract(json, '$.hash') FROM NotImportant WHERE
json_extract(json, '$.hash') = $someId"
24471899
% mydb eval "SELECT json_extract(json, '$.hash') FROM NotImportant WHERE
json_extract(json, '$.hash') = :someId"
%

It looks like the minute I try to have sqlite3 do the variable
interpolation, it also breaks the JSON path -- and I can't escape the
dollar sign in the JSON path because that makes it invalid. Setting the
.hash variable also doesn't work. Neither does setting the JSON path in a
variable and attempting to interpolate that variable as well:

% putlog $anotherQuery4
LOG: SELECT * FROM NotImportant WHERE json_extract(json, :json_path) =
:someId
% mydb eval $anotherQuery4
% set anotherQuery4 "SELECT * FROM NotImportant WHERE json_extract(json,
'$json_path') = $someId"
SELECT * FROM NotImportant WHERE json_extract(json, '$.hash') = 24471899
% mydb eval $anotherQuery4
24471899 ... data ...

I've tried various escapes placed here and there, I've tried ways to
restate the query... that $someId variable is almost always going to be an
integer but I don't want to allow any failure/possible injection there
regardless, so I do want sqlite3 to do the proper escaping/handling for it,
but I also want to be able to use json_extract in my queries -- the
alternative is table scanning or some other hack.

Thanks for any help in advance!
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to