Skip to content

[FORMATTING] MS Access Query where column names have spaces #646

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

Closed
cjbarth opened this issue Oct 5, 2023 · 2 comments
Closed

[FORMATTING] MS Access Query where column names have spaces #646

cjbarth opened this issue Oct 5, 2023 · 2 comments
Labels

Comments

@cjbarth
Copy link

cjbarth commented Oct 5, 2023

Input data

Which SQL and options did you provide as input?

SELECT 

TextLength_infor.Count,
LengthText_wm.Count,
Weight_infor.Count,
WeightText_wm.Count,
Image1.Count

FROM (SELECT COUNT([Length Text_infor]) AS Count FROM Assessment WHERE [Length Text_infor] <> "") AS TextLength_infor,
(SELECT COUNT([Length Text_wm]) AS Count FROM Assessment WHERE [Length Text_wm] <> "") AS LengthText_wm,
(SELECT COUNT([Weight_infor]) AS Count FROM Assessment WHERE [Weight_infor] <> "") AS Weight_infor,
(SELECT COUNT([Weight Text_wm]) AS Count FROM Assessment WHERE [Weight Text_wm] <> "") AS WeightText_wm,
(SELECT COUNT([Image 1]) AS Count FROM Assessment WHERE [Image 1] <> "") AS Image1

Error

Unable to format SQL: Error: Parse error: Unexpected "[Length Te" at line 9 column 20

Usage

  • How are you calling / using the library?
    • I'm using this library as part of the VS Code Extension, but am reporting here as this is decidedly a problem with token parsing related to the dialect of SQL.
    • I have no other SQL formatting tools installed, in fact, this is the first SQL anything that I've installed in VS Code.
    • I'm using the SQLFlavour of sql since there doesn't seem to be one that is related to MS Access SQL.
  • What SQL language(s) does this apply to?
    • I'm working with a query in MS Access where spaces are allowed in column names if they are contained in brackets []
  • Which SQL Formatter version are you using?
    • I just installed from the Marketplace and the version appears to be listed as v1.6.0
@cjbarth cjbarth added the bug label Oct 5, 2023
@cjbarth cjbarth changed the title [FORMATTING] Issue Title Here [FORMATTING] MS Access Query where column names have spaces Oct 5, 2023
@nene
Copy link
Collaborator

nene commented Oct 5, 2023

Although MS Access is not currently supported, treating it as Transact-SQL will most likely do the job.

Simply select "Transact-SQL" as the SQL dialect in extension settings. See the FAQ

Also, I suggest switching from the prettier-sql-vscode extension to sql-formatter-vsc extension. The former is no longer maintained.

@cjbarth
Copy link
Author

cjbarth commented Oct 5, 2023

Indeed, using Transact SQL helped solve this problem. And thanks for the tip of the extension. I can't believe how many people are using the forked one and the deprecated on. I wonder if there is a way to help people find the correct one. You might consider putting a link to the VS Code extension at the top of your readme so that those that are coming here from the other extension will see that they have the wrong one.

Anyway, thanks for your help on this.

@cjbarth cjbarth closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants