You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jamie Hankins (JIRA)" <ji...@apache.org> on 2017/04/27 19:27:04 UTC

[jira] [Comment Edited] (CASSANDRA-10263) Insert in Cassandra in a collection, values with single quote

    [ https://issues.apache.org/jira/browse/CASSANDRA-10263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15987282#comment-15987282 ] 

Jamie Hankins edited comment on CASSANDRA-10263 at 4/27/17 7:26 PM:
--------------------------------------------------------------------

By that logic, why isn't the JSON result also escaped?

{code}
cqlsh:gii> insert into test (name,values) values ('Tu''pac',{'fo''o':'josemy''s house'});
cqlsh:gii> select * from test;
 name    | values
---------+------------------------------
  Tu'pac | {'fo''o': 'josemy''s house'}
cqlsh:gii> select json * from test;
 [json]
----------------------------------------------------------
 {"name": "Tu'pac", "values": {"fo'o": "josemy's house"}}
{code}

The easiest thing is just to say "by design", but returning the escaped single-quotes is counter to any other DBMS.

As an aside, PostgreSQL doesn't do maps, but here's what an array looks like:

{code}
derms=# create table test ( name text, items text[] );
CREATE TABLE
derms=# insert into test (name,items) values ('Fred',ARRAY['item''s delight','Jason''s house']);
INSERT 0 1
derms=# select * from test;
 name |               items
------+------------------------------------
 Fred | {"item's delight","Jason's house"}
{code}


was (Author: jamiehankins):
By that logic, why isn't the JSON result also escaped?

{code}
cqlsh:gii> insert into test (name,values) values ('Tu''pac',{'fo''o':'josemy''s house'});
cqlsh:gii> select * from test;
 name    | values
---------+------------------------------
  Tu'pac | {'fo''o': 'josemy''s house'}
cqlsh:gii> select json * from test;
 [json]
----------------------------------------------------------
 {"name": "Tu'pac", "values": {"fo'o": "josemy's house"}}
{code}

The easiest thing is just to say "by design", but returning the escaped single-quotes is counter to any other DBMS.

> Insert in Cassandra in a collection, values with single quote
> -------------------------------------------------------------
>
>                 Key: CASSANDRA-10263
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10263
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Jduarte
>            Assignee: Benjamin Lerer
>         Attachments: terminal.png
>
>
> I think there is a problem with single quotes in collection fields. This is what I try:
> Table: {{CREATE TABLE test (name text, foo map<text,text>, PRIMARY KEY(name));}}
> Insert:  {code}INSERT INTO test (name, foo) VALUES ( 'jos''emy',{'foo':'josemy''s houñse'});{code}
> Query: {{SELECT * FROM  test;}}
> {code}
>  name    | foo
> -----------+-----------------------------
>  jos'emy | {'foo': 'josemy''s houñse'}
> {code}
> As you can see, Cassandra replace the double quote in the simple "name" field, but does not replace the quotes in the field inside the map. The result (I think) should be:
> {code}
>  name    | foo
> ---------+-----------------------------
>  jos'emy |   {'foo': 'josemy's houñse'}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org