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

A complete SQL statement will be truncated at a location that may be a keyword #226

Closed
Drogon1573 opened this issue May 11, 2019 · 8 comments

Comments

3 participants
@Drogon1573
Copy link

commented May 11, 2019

Bug information
If your SQL statement exists as part of the SQL keyword, SQLTools will truncate here.

How to make this bug shows up

  1. Create a table in SQL Server Express 2017, which the table name is called [Market].[dbo].[Goods]. The table has 5 columns. They are [Name], [Series], [TradeMark], [MadeIn] and [Price].
  2. Connect to database [Market] with SQLTools.
  3. Show table records of [Market].[dbo].[Goods] using keyboard shortcuts Ctrl+E Ctrl+S.
  4. Bug has appeared! In SQLTools Results window, there are label Showing 1 [Market].[dbo].[Goods] records - which is expected - and ods] - which is unexpected.
  5. The first label shows results exactly what I want, but the second label returns nothing and its query statement is also a mess.

Expected behavior
I hope that SQLTools can ignore keywords GO in word Goods and do not truncate it.

Screenshots
Database Details
Reproduce Guide 1
image
image
image

Desktop (please complete the following information):

  • SQLTools Version: 0.18.2
  • VSCode Version: 1.33.1 (system setup)
  • Dialect Used: MSSQL, with SQL Server Express 2017
  • OS: Windows 10 Home China 1809 17763.475

Additional context
I am a Simplified Chinese user and this is my first time to report an issue on GitHub. Due to the use of the Simplified Chinese system, the menu buttons and prompts in the screenshot are all in Chinese, please forgive me.

@Drogon1573 Drogon1573 added the bug label May 11, 2019

@project-bot project-bot bot added this to To do in Kanban May 11, 2019

@ransagy

This comment has been minimized.

Copy link

commented May 19, 2019

I've noticed this too; I believe this is the GO keyword being identified in the middle of such queries/names and interpreted as a split in the queries.

@Drogon1573

This comment has been minimized.

Copy link
Author

commented May 19, 2019

The Following advice was suggested by my classmate. Is it easy to realize?

Use full word matching to solve this problem.

If the GO or other keyword is surrounded by only whitespace characters \s, newline characters (\r, \n), or on a separate line, then these words are recognized as keywords; otherwise, they are associated with adjacent characters (strings) and treated as a whole, not identified as a keyword.

@ransagy

This comment has been minimized.

Copy link

commented May 19, 2019

I haven't looked through the codebase, so only @mtxr can say better, but i assume it's a case of just correcting a regex in a similar manner to what your classmate suggested, yeah.

Places that could be relevant after searching the codebase:

https://github.com/mtxr/vscode-sqltools/blob/master/packages/core/dialect/mssql/index.ts#L78 - Seems to be OK if i check the regex on its own - Only detects and replaces GO keywords wrapped by space or tabs, and only in the beginning and ending of lines.

https://github.com/mtxr/vscode-sqltools/blob/master/packages/core/utils/query/parse.ts#L123-L129 - Can't quite follow the algorithm here without delving into the other parser parts yet.

https://github.com/mtxr/vscode-sqltools/blob/master/packages/extension/language/sql.tmLanguage.json#L31 - This defines the keyword list, Maybe VSCode itself is doing something odd with it?

I should really install a VSCode extension dev env at some point just to check these things. If you don't get to this "soon", @mtxr , let me know - I'll try to take a shot at it, Seems like a relatively "simple" bug to start with?

@mtxr

This comment has been minimized.

Copy link
Owner

commented May 19, 2019

Hey guys, I'll take a look at this today and release it in the next release as well.

The parser is a third-party based code, so I'll need to dig a bit deeper to fix and write tests to avoid this from happening in the future.

@mtxr mtxr closed this in a73f183 May 20, 2019

Kanban automation moved this from To do to To be released May 20, 2019

@mtxr mtxr self-assigned this May 20, 2019

@project-bot project-bot bot moved this from To be released to In progress in Kanban May 20, 2019

@Drogon1573

This comment has been minimized.

Copy link
Author

commented May 20, 2019

I received an e-mail from GitHub that you fixed this bug and closed the issue. I can't wait reciving the new release and update to it! Thanks @mtxr 🎉🎉🎉

@mtxr mtxr moved this from In progress to To be released in Kanban May 20, 2019

@mtxr

This comment has been minimized.

Copy link
Owner

commented Jun 2, 2019

Hi @Drogon1573!

How is it going with the extension? Is it working as expected now? Hope so!

Just came to remember, if you like the project, please consider a donation or reviewing it on VSCode marketplace. That you help it to keep evolving.

Thanks!

@Drogon1573

This comment has been minimized.

Copy link
Author

commented Jun 2, 2019

@mtxr

I have received your comment. Thank you very much for your ability to fix the bug in time. Now it can work correctly.

image

image

I want to donate to your project. But I have no credit cards to donate in another currency. Sorry for that. 😭

@mtxr

This comment has been minimized.

Copy link
Owner

commented Jun 2, 2019

@Drogon1573 nice!

No problem, just please, take a few minutes to review it at https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools

That will help more people find the extension as well. More people using, more feedbacks, more improvements, more donations 😃

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.