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] Querying a semi-structured data with an element name that is a reserved clause is incorrect #706

Closed
chaupow opened this issue Jan 25, 2024 · 4 comments
Labels

Comments

@chaupow
Copy link

chaupow commented Jan 25, 2024

Hi! 👋

Input data

Which SQL and options did you provide as input?
with "language": "snowflake"

SELECT
  details:type
FROM
  transactions

Expected Output

SELECT
  details:type
FROM
  transactions

Actual Output

SELECT
  details:
type
FROM
  transactions

Usage

We're using snowflake and unfortunately some of our JSON fields have the key type which is identified as a reserved clause and incorrectly put in the next line.

We can prevent this by using details:"type" but it would be great if it would work without quotes as well.

This is especially an issue because we would love to use "keywordCase": "upper" but this breaks the query because key names are case sensitive and details:TYPE fails to query the intended lookup.

  • How are you calling / using the library?
sqlFormatter.format(sqlContent, {"language": "snowflake"});
  • What SQL language(s) does this apply to?
    snowflake

  • Which SQL Formatter version are you using?
    15.1.2

Thank youuuuuuuuu 🙏

@chaupow chaupow added the bug label Jan 25, 2024
@nene
Copy link
Collaborator

nene commented Jan 25, 2024

Thanks for reporting.

Although I apparently have documented this :-syntax of Redshift, I haven't actually implemented any support for it.

Interestingly I just recently fixed a similar issue for Transact-SQL. So most likely some similar solution could be done in here.

@nene nene closed this as completed in 821186a Jan 26, 2024
@nene
Copy link
Collaborator

nene commented Jan 26, 2024

I was mistaken. This syntax was supported, but as the issue title says, the problem was only the case when a keyword occurred after :.

Now treating : similarly to . that's commonly used as a table.column separator.

@nene
Copy link
Collaborator

nene commented Jan 26, 2024

Fixed in 15.1.3

@chaupow
Copy link
Author

chaupow commented Jan 26, 2024

Oh wow this was amazing quick!! ⚡✨

Thanks so much for fixing so promptly and pushing a new version out 🥹
I really appreciate it!

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