diff --git a/docs/v0.1.0/.documenter-siteinfo.json b/docs/v0.1.0/.documenter-siteinfo.json index b35f054..e0898d3 100644 --- a/docs/v0.1.0/.documenter-siteinfo.json +++ b/docs/v0.1.0/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-08T11:10:42","documenter_version":"1.4.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-08T17:04:59","documenter_version":"1.4.1"}} \ No newline at end of file diff --git a/src/tokens.jl b/src/tokens.jl index ca3857d..9bf19d4 100644 --- a/src/tokens.jl +++ b/src/tokens.jl @@ -49,7 +49,11 @@ inject a value. Often this happens when using `\$(...)` to embed values into a q instead write something like `/ \$(escape_value(axis)) @ \$(escape_value(property))`. """ function escape_value(value::AbstractString)::String - return replace(value, (character -> !is_value_char(character)) => s"\\\0") # NOJET + if value == "" + return "''" + else + return replace(value, (character -> !is_value_char(character)) => s"\\\0") # NOJET + end end """ @@ -59,7 +63,11 @@ Undo [`escape_value`](@ref), that is, given an `escaped` value with a `\\` chara the `\\` to get back the original string value. """ function unescape_value(escaped::AbstractString)::String - return replace(escaped, r"\\(.)" => s"\1") + if escaped == "''" + return "" + else + return replace(escaped, r"\\(.)" => s"\1") + end end """ diff --git a/test/queries.jl b/test/queries.jl index 8a51afa..936a414 100644 --- a/test/queries.jl +++ b/test/queries.jl @@ -45,6 +45,10 @@ end nested_test("queries") do daf = MemoryDaf(; name = "memory!") + nested_test("empty") do + @test string(Query("/ metacell != ''")) == "/ metacell != ''" + end + nested_test("combine") do nested_test("one") do @test string(Lookup("score")) == ": score" diff --git a/test/tokens.jl b/test/tokens.jl index efd30dc..1e023aa 100644 --- a/test/tokens.jl +++ b/test/tokens.jl @@ -18,9 +18,15 @@ end nested_test("tokens") do nested_test("escape") do + nested_test("empty") do + test_escape_value("", "''") + return nothing + end + nested_test("unicode") do test_escape_value("א", "א") - return test_escape_value("ת", "ת") + test_escape_value("ת", "ת") + return nothing end nested_test("alpha") do