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

Some SQL server syntax does not support parsing #1682

Closed
SconyHui opened this issue Dec 5, 2022 · 15 comments · Fixed by #1676
Closed

Some SQL server syntax does not support parsing #1682

SconyHui opened this issue Dec 5, 2022 · 15 comments · Fixed by #1676

Comments

@SconyHui
Copy link

SconyHui commented Dec 5, 2022

Hi,
I found it unsupported when parsing part of SQLServer syntax.
example:
1, select [id],[name],[age] from [Student]
Because the column name contains the special symbol "[" or "]"
2, declare @Flag int
set @Flag = 1
Because the column name contains the special symbol "@" in SetStatement
3, begin
...
end
This syntax is not supported
4, use LibName
go
...
go
This syntax is not supported

@manticore-projects
Copy link
Contributor

Greetings.

Please use the latest JSQLParser 4.5 or better JSQLParser 4.6 Snapshot since all the Syntax are supported.
Please refer to https://manticore-projects.com/JSQLParser/usage.html#define-the-parser-features for activation of T-SQL Squared Bracket Quotation.

If you still face challenges, then please provide the specific query, shortened/simplified as much as possible.

@SconyHui
Copy link
Author

SconyHui commented Dec 5, 2022

Yes, I'm using version 4.6

@SconyHui
Copy link
Author

SconyHui commented Dec 5, 2022

eg:
select [id],[name],[age] from [Student]
image

@manticore-projects
Copy link
Contributor

Please activate SquaredBracket Quotation.

@manticore-projects
Copy link
Contributor

select [id],[name],[age] from [Student]

You can test it online here.

@SconyHui
Copy link
Author

SconyHui commented Dec 5, 2022

Thank you. I'll try

@SconyHui
Copy link
Author

SconyHui commented Dec 5, 2022

Thank you. The question has been solved
But I also have problems using this syntax
image

@manticore-projects
Copy link
Contributor

SET @localVariable is likely not supported.

You would either need to contribute a PR or sponsor the implementation.

@SconyHui
Copy link
Author

SconyHui commented Dec 5, 2022

I will apply to the company

@SconyHui
Copy link
Author

SconyHui commented Dec 6, 2022

Hi,
Is the combination of BEGIIN END and IF not supported
image

@manticore-projects
Copy link
Contributor

Greetings.

Please refer to https://manticore-projects.com/JSQLParser/_static/JSqlParserCC.xhtml#Block

  1. Begin End Blocks of statements are supported

  2. IF ELSE Statements are supported

However, your example of IF ELSE with BLOCK is not supported.
It would depend on a major rewrite and/or refactoring since those constructs are MS SQL Server specific.

@SconyHui
Copy link
Author

SconyHui commented Dec 6, 2022

Thank you very much. I will find another way to solve this problem

@manticore-projects
Copy link
Contributor

manticore-projects commented Dec 6, 2022 via email

manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Dec 9, 2022
Make `If... Else...` statements work with Blocks
Make `Statement()` production work with `Block()`
Rewrite the `Block()` related Unit Tests

fixes JSQLParser#1682
manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Dec 9, 2022
Make `SetStatement` parse Objects instead of Names only
Add Grammar to accept `UserVariable` (e.g. "set @Flag = 1")
Add Test Case for `UserVariable`

fixes JSQLParser#1682
@wumpz
Copy link
Member

wumpz commented Dec 10, 2022

@manticore-projects Did he sponsor the set improvement?

@manticore-projects
Copy link
Contributor

@manticore-projects Did he sponsor the set improvement?

No. :(
But I have to parse some MS SQL Server scripts for myself and so I did not mind.

wumpz pushed a commit that referenced this issue Dec 22, 2022
* support clickhouse global keyword in join

* fix: add missing public Getter

Add public Getter for `updateSets`
Fixes #1630

* feat: Clickhouse GLOBAL JOIN

All credits to @julianzlzhang

fixes #1615
fixes #1535

* feat: IF/ELSE statements supports Block

Make `If... Else...` statements work with Blocks
Make `Statement()` production work with `Block()`
Rewrite the `Block()` related Unit Tests

fixes #1682

* fix: Revert unintended changes to the Special Oracle Tests

* fix: `SET` statement supports `UserVariable`

Make `SetStatement` parse Objects instead of Names only
Add Grammar to accept `UserVariable` (e.g. "set @Flag = 1")
Add Test Case for `UserVariable`

fixes #1682

* feat: Google Spanner Support

Replaces PR #1415, all credit goes to @s13o
Re-arranged some recently added Tokens in alphabetical order
Update Keywords

* fix: fix JSonExpression, accept Expressions

Make JSonExpression accept Expressions
Add Testcase
Expose Idents() and Operators()
Fixes #1696

* test: add Test for Issue #1237

Co-authored-by: Zhang Zhongliang <zhangzhongliang@xiaomi.com>
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 a pull request may close this issue.

3 participants