Open skyrod-vactai opened 11 months ago
yep \" is not working
There is another issue with strings. I've tried avoiding the problem reported here by using raw string notation e.g. ___"I'm a raw string"___
. But this will fail when a hash char (#
) is included in the string.
The following example will FAIL with reason The query parser has encountered unexpected input / end of input at 58..58
?[repository_uri, oid, data, size] <- [['test', '000', ___\"John said 'I like color #298594'\"___, 30]]
:put blob {repository_uri, oid => data, size}
Just removing the #
char makes it work.
I am guessing this might be because Rust uses #
instead of _
for raw strings?
The combination of the issue reported by @skyrod-vactai and this makes it impossible to store arbitrary strings in CozoDB. For example storing JSON, HTML, CSS, XML, SVG and any other source code that typically contains multiple instances of double, single quotes and the hash char.
The following simpler example will also fail
?[repository_uri, oid, data, size] <- [['test', '000', ___\"#298594\"___, 8]]
:put blob {repository_uri, oid => data, size}
I just reported this as a separate issue in #234
@aramallo @skyrod-vactai i figure out workaround - if i pass strings as params to a query it is works . so you could use variables binded to a query params - it is working well
Do you mind posting an example here? Thanks a lot @Volland
BTW the solution I posted works on the parser online playground (which I guess uses the latest version) but not when used inside coso, I need to check upgrading the parser lib version in cozo and doublecheck
@aramallo sure So query like ?[id , label] := nodes[id, label], label in [ '\" boom \"'] will fail I move it to a param ?[id , label] := nodes[id, label], is_in(label , $list) where {list : [ '\" boom \"']}
Ah nice thanks @Volland !!
According to the docs:
And from the tutorial:
JSON rules do allow
\"
and serde_json produces JSON with that sequence. But cozo doesn't accept it:I ran into this while trying to insert data. What I did was format the row data as JSON, and spliced that into a generic query that does a :put. If there's a better way to insert data let me know. I know you can import an entire JSON file but I want something I can call from my program (I'm using the cozo library in a rust program).