[
https://issues.apache.org/jira/browse/CASSANDRA-21746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Brandon Williams updated CASSANDRA-21746:
-----------------------------------------
Bug Category: Parent values: Correctness(12982)Level 1 values: Recoverable
Corruption / Loss(12986)
Complexity: Normal
Component/s: CQL/Semantics
Discovered By: User Report
Fix Version/s: 5.0.x
6.x
7.x
Severity: Normal
Status: Open (was: Triage Needed)
> SELECT JSON output can't be read back by INSERT JSON for a column or UDT
> field whose name begins and ends with a double quote
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-21746
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21746
> Project: Apache Cassandra
> Issue Type: Bug
> Components: CQL/Semantics
> Reporter: Nadav Har'El
> Priority: Normal
> Fix For: 5.0.x, 6.x, 7.x
>
>
> SELECT JSON prints a case-sensitive column name (one with uppercase letters)
> in an extra pair of quotes, e.g. "\"Foo\"", and INSERT JSON (and fromJson()
> for UDT fields) treats a name in quotes as case-sensitive, stripping one pair
> of quotes. The same convention applies to the field names of a user-defined
> type.
> But a name which itself begins and ends with a double-quote character -
> allowed in CQL, e.g. the quoted identifier """foo""", whose name is "foo"
> including the quotes - is printed by SELECT JSON without the extra quotes,
> because it has no uppercase letters. INSERT JSON then strips the name's own
> quotes, and writes the value to a different column or field. Tested on
> Cassandra 5.0.9 and 6.0-alpha2:
> {code}
> CREATE TABLE t (p int PRIMARY KEY, """foo""" int, foo int);
> INSERT INTO t (p, """foo""", foo) VALUES (1, 1, 2);
> SELECT JSON * FROM t WHERE p = 1;
> -- {"p": 1, "\"foo\"": 1, "foo": 2}
> INSERT INTO t JSON '{"p": 2, "\"foo\"": 1, "foo": 2}';
> SELECT JSON * FROM t WHERE p = 2;
> -- {"p": 2, "\"foo\"": null, "foo": 1} <- the value 1 went into foo, and
> foo's value 2 was lost
> {code}
> The same happens with a UDT field named """foo""" (in UserType.toJSONString()
> and fromJSONObject()).
> The fix is to also print a name which begins and ends with a double quote in
> an extra pair of quotes, e.g. "\"\\\"foo\\\"\"", so that stripping one pair
> of quotes restores the original name.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]