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

fix: do not capitalize reserved words for object names #191

Merged
merged 1 commit into from
Dec 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ASTcreate_change_stream_statement(DdlParser p, int id) {
}

public String getName() {
return AstTreeUtils.getChildByType(children, ASTname.class).toString();
return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class), false);
}

public ASTchange_stream_for_clause getForClause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ASTcreate_index_statement(DdlParser p, int id) {
}

public String getIndexName() {
return AstTreeUtils.getChildByType(children, ASTname.class).toString();
return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class), false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ASTcreate_search_index_statement(DdlParser p, int id) {
}

public String getName() {
return AstTreeUtils.tokensToString(getChildByType(children, ASTname.class));
return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class), false);
}

private void validateChildren() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ASTcreate_table_statement(DdlParser p, int id) {
}

public String getTableName() {
return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class));
return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class), false);
}

public Map<String, ASTcolumn_def> getColumns() {
Expand Down
22 changes: 22 additions & 0 deletions src/test/resources/ddlParserValidation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,26 @@ CREATE SEARCH INDEX AlbumsIndex
ON Albums ( AlbumTitle_Tokens )
OPTIONS (sort_order_sharding=TRUE)

== Test 14 create table with reserved word word name

CREATE TABLE usage (
intcol INT64,
structcol1 STRUCT < col1 INT64, col2 INT64 >,
structcol2 STRUCT <>
) PRIMARY KEY (intcol ASC)

== Test 15 create index with reserved word word name

CREATE INDEX IF NOT EXISTS usage ON usage_table ( mycol ASC )

== Test 16 create search index with reserved word name

CREATE SEARCH INDEX usage
ON usage_table ( some_token )
OPTIONS (sort_order_sharding=TRUE)

== Test 16 change stream with reserved word name

CREATE CHANGE STREAM usage FOR table1

==
Loading