typedb / typedb-console

TypeDB Console: CLI for TypeDB and TypeDB Cluster
https://typedb.com
Mozilla Public License 2.0
7 stars 16 forks source link

Disable Jline backslash stripping #188

Closed flyingsilverfin closed 2 years ago

flyingsilverfin commented 2 years ago

What is the goal of this PR?

JLine line parser, which handles console's REPL, no longer swallows backslahes and other escape characters.

Previously, this lead to unexpected behaviour:

tmp::data::write> insert $x "hello \" world" isa val;

[TQL03] TypeQL Error: There is a syntax error at line 1:
insert $x "hello " world" isa val;
                   ^
mismatched input 'world' expecting {';', 'has'}

Now, JLine keeps all the escape characters in place and hands the query parsing to TypeQL:

tmp::data::write> insert $x "hello \" world" isa val;

{ $x "hello \" world" isa val; }

What are the changes implemented in this PR?

flyingsilverfin commented 2 years ago

@jamesreprise let me know if this aligns with expected behaviour in a database console!

jamesreprise commented 2 years ago

@jamesreprise let me know if this aligns with expected behaviour in a database console!

jameswilliams=# INSERT INTO test (mystr) VALUES ('hello \" world');
INSERT 0 1
jameswilliams=# SELECT * FROM test;
     mystr      
----------------
 hello \" world
(1 row)

This looks in line with your given example. However...

jameswilliams=# INSERT INTO test (mystr) VALUES ('hello '' world');
INSERT 0 1
jameswilliams=# SELECT * FROM test;
     mystr     
---------------
 hello ' world
(1 row)

Note that '' is the SQL way of escaping a single quote. This doesn't feel like it quite lines up. Is this something we're concerned about @flyingsilverfin?