Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed case sensitivity on label usage of reserved keyword #1040

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion regress/expected/cypher_create.out
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,41 @@ $$) as (a agtype);
ERROR: variable e already exists
LINE 3: CREATE (p)-[e:new]->(a)
^
-- Validate usage of keywords as labels is supported and case sensitive
SELECT * FROM cypher('cypher_create', $$
CREATE (a:CREATE)
RETURN a
$$) as (a agtype);
a
-----------------------------------------------------------------------
{"id": 5348024557502465, "label": "CREATE", "properties": {}}::vertex
(1 row)

SELECT * FROM cypher('cypher_create', $$
CREATE (a:create)
RETURN a
$$) as (a agtype);
a
-----------------------------------------------------------------------
{"id": 5629499534213121, "label": "create", "properties": {}}::vertex
(1 row)

SELECT * FROM cypher('cypher_create', $$
CREATE (a:CrEaTe)
RETURN a
$$) as (a agtype);
a
-----------------------------------------------------------------------
{"id": 5910974510923777, "label": "CrEaTe", "properties": {}}::vertex
(1 row)

--
-- Clean up
--
DROP TABLE simple_path;
DROP FUNCTION create_test;
SELECT drop_graph('cypher_create', true);
NOTICE: drop cascades to 16 other objects
NOTICE: drop cascades to 19 other objects
DETAIL: drop cascades to table cypher_create._ag_label_vertex
drop cascades to table cypher_create._ag_label_edge
drop cascades to table cypher_create.v
Expand All @@ -788,6 +816,9 @@ drop cascades to table cypher_create."Part"
drop cascades to table cypher_create.new
drop cascades to table cypher_create.node
drop cascades to table cypher_create.n1
drop cascades to table cypher_create."CREATE"
drop cascades to table cypher_create."create"
drop cascades to table cypher_create."CrEaTe"
NOTICE: graph "cypher_create" has been dropped
drop_graph
------------
Expand Down
18 changes: 18 additions & 0 deletions regress/sql/cypher_create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,24 @@ SELECT * FROM cypher('cypher_create', $$
CREATE (p)-[e:new]->(a)
$$) as (a agtype);


-- Validate usage of keywords as labels is supported and case sensitive

SELECT * FROM cypher('cypher_create', $$
CREATE (a:CREATE)
RETURN a
$$) as (a agtype);

SELECT * FROM cypher('cypher_create', $$
CREATE (a:create)
RETURN a
$$) as (a agtype);

SELECT * FROM cypher('cypher_create', $$
CREATE (a:CrEaTe)
RETURN a
$$) as (a agtype);

--
-- Clean up
--
Expand Down
3 changes: 3 additions & 0 deletions src/backend/parser/cypher_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ int cypher_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, ag_scanner_t scanner)
* case sensitivity
*/
lvalp->keyword = GetScanKeyword(kwnum, &CypherKeyword);
ident = pstrdup(token.value.s);
truncate_identifier(ident, strlen(ident), true);
lvalp->string = ident;
*llocp = token.location;
return CypherKeywordTokens[kwnum];
}
Expand Down