Skip to content

Comments

MSSQL: prevent statement-starting keywords from being consumed as implicit aliases#2233

Open
yoabot-droid wants to merge 1 commit intoapache:mainfrom
yoabot-droid:mssql-implicit-alias-disambiguation
Open

MSSQL: prevent statement-starting keywords from being consumed as implicit aliases#2233
yoabot-droid wants to merge 1 commit intoapache:mainfrom
yoabot-droid:mssql-implicit-alias-disambiguation

Conversation

@yoabot-droid
Copy link

Problem

In T-SQL multi-statement scripts delimited by newlines, the parser was consuming statement-starting keywords (DECLARE, EXEC/EXECUTE, INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE, PRINT, WHILE, RETURN, THROW, RAISERROR, MERGE) as implicit aliases for the preceding SELECT item or table reference, then failing on the next token.

Fix

Extended is_select_item_alias() and is_table_factor_alias() in MsSqlDialect to return false for all of these keywords, matching the existing treatment of IF and ELSE.

Test

Adds test_tsql_statement_keywords_not_implicit_aliases covering column and table alias cases across the full affected keyword set.

…licit aliases

In T-SQL multi-statement scripts delimited by newlines, the parser was
incorrectly consuming statement-starting keywords (DECLARE, EXEC/EXECUTE,
INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE, PRINT, WHILE,
RETURN, THROW, RAISERROR, MERGE) as implicit aliases for the preceding
SELECT item or table reference, then failing on the next token.

Extended is_select_item_alias() and is_table_factor_alias() in MsSqlDialect
to return false for all of these keywords, matching the existing treatment
of IF and ELSE.

Adds test_tsql_statement_keywords_not_implicit_aliases covering both column
and table alias cases across the affected keyword set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant