typeql
typeql copied to clipboard
attribute with datatype of string doesn't accept a string containing a slash
Grakn version: 1.5 SNAPSHOT
define
title sub attribute,
datatype string;
insert $x isa title; $x "/";
Expected outcome:
the new instance of attribute title
to be created with value "/"
.
Actual outcome
Error: syntax error at line 1:
insert $x isa title; $x "/";
^
token recognition error at: '"/'
syntax error at line 1:
insert $x isa title; $x "/";
^
token recognition error at: '";'
syntax error at line 1:
insert $x isa title; $x "/";
^
no viable alternative at input '$x '
syntax error at line 1:
insert $x isa title; $x "/";
^
extraneous input '$x' expecting {<EOF>, 'match', 'define', 'undefine', 'insert', 'compute'}
All uncommitted data is cleared
@haikalpribadi the team had a discussion on this and think this is a critical issue we need to resolve. I'm gonna reopen this for now until we come to a conclusive decision. there was more to the discussion than what's documented here. let's talk about it when you get the chance
To clarify what @sorsaffari meant, we should be able to store a string "
. The escape character \
should not be stored along with it.
The following snippet should insert "
and not \"
into the database:
grakn> define name sub attribute, datatype string;
grakn> insert $n isa name; $n "\"";
{$n "\"" isa name;}
This is the behaviour of most databases (eg., Postgres, MySQL) and therefore I think this should be how Grakn behaves as well.
But why? I'm not sure I understand why you need to store an escaped quote? A string with a quote is not wrong. You can easily write that like this, '"'
, for example. This is accepted. In different languages, you can provide a string with single quotes '
too. It's just in Java you can only provide strings in double quotes "
which means you need to escape your actual double quotes "
in the string itself, but this only needs one backslash \
in java, which will be rendered first during the string assignment.
So I'm not following where this is an issue. If the user writes the string like \"
then that should be stored as is. @sorsaffari @lolski
The main concern right now is that we aren't actually able to store a string containing " AND ' within a Graql string without a backslach being stored in Grakn as well. We will consider further what the best solution for this problem is.
This is related to and resolved/discussed in #224