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

[FORMATTING] tsql: Some schema or column names follow keywordCase #812

Closed
rmja opened this issue Dec 20, 2024 · 2 comments
Closed

[FORMATTING] tsql: Some schema or column names follow keywordCase #812

rmja opened this issue Dec 20, 2024 · 2 comments
Labels

Comments

@rmja
Copy link

rmja commented Dec 20, 2024

When I run with keywordCase: "upper", then it seems to also convert at positions which are clearly e.g. schema name or column name.

Input data

CREATE TABLE Catalog.Catalog(
    Col1 int,
    Floor int
)

Expected Output

CREATE TABLE Catalog.Catalog(
    Col1 int,
    Floor int
)

Actual Output

CREATE TABLE CATALOG.Catalog(
    Col1 int,
    FLOOR int
)

Usage

  • How are you calling / using the library? prettier-plugin-sql
  • What SQL language(s) does this apply to? tsql
  • Which SQL Formatter version are you using? 15.4.7
@rmja rmja added the bug label Dec 20, 2024
@nene
Copy link
Collaborator

nene commented Dec 21, 2024

Thanks for reporting.

Really two separate issues here:

  • table.column style constructs should never be detected as keywords. This actually works for the column name part, but for some reason I haven't done it for the table name part. Probably these cases don't happen quite as often.
  • Function names (like floor) should not be detected as keywords. Currently inside the formatter all function names that aren't followed by ( are treated as keywords. Though I'm not sure why. Must be some reason... Will need to dig deeper.

@nene
Copy link
Collaborator

nene commented Dec 21, 2024

Aha... looks like the only reason was that some special functions like CURRENT_TIME can be used without parenthesis. Probably better to just treat these as plain keywords or have some special logic for them, as there is really only a limited set of these things.

For now I'll just switch to treating all such function names as plain identifiers, which I think solves more problems than the previous approach.

@nene nene closed this as completed in 0d39810 Dec 21, 2024
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