Skip to content

[FORMATTING] Formatter adding space for sqlc macros #786

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
B4Dmonkey opened this issue Oct 14, 2024 · 1 comment
Closed

[FORMATTING] Formatter adding space for sqlc macros #786

B4Dmonkey opened this issue Oct 14, 2024 · 1 comment
Labels

Comments

@B4Dmonkey
Copy link

Input data

Which SQL and options did you provide as input?

SELECT
  sqlc.embed(transactions),
  sqlc.embed(documents_meta)
FROM
  transactions
  JOIN documents_meta ON transactions.document_id=documents_meta.id
WHERE
  transactions.posting_date>=@start_date
  AND transactions.posting_date<=@end_date
  AND documents_meta.publishing_date=(
    SELECT
      MAX(publishing_date)
    FROM
      documents_meta
  )
ORDER BY
  transactions.posting_date DESC;

Expected Output

SELECT
  sqlc.embed(transactions),
  sqlc.embed(documents_meta)
FROM
  transactions
  JOIN documents_meta ON transactions.document_id=documents_meta.id
WHERE
  transactions.posting_date>=@start_date
  AND transactions.posting_date<=@end_date
  AND documents_meta.publishing_date=(
    SELECT
      MAX(publishing_date)
    FROM
      documents_meta
  )
ORDER BY
  transactions.posting_date DESC;

Actual Output

SELECT
  sqlc.embed (transactions),
  sqlc.embed (documents_meta)
FROM
  transactions
  JOIN documents_meta ON transactions.document_id=documents_meta.id
WHERE
  transactions.posting_date>=@start_date
  AND transactions.posting_date<=@end_date
  AND documents_meta.publishing_date=(
    SELECT
      MAX(publishing_date)
    FROM
      documents_meta
  )
ORDER BY
  transactions.posting_date DESC;

Usage

  • How are you calling / using the library?
    I'm calling this using the prettier vs code pluqin
  • What SQL language(s) does this apply to?
    This is for sqlite when paired with sqlc
  • Which SQL Formatter version are you using?
    v11.0.0

Additional information
When I'm running the formatter it's inserting a space for sqlc.embed(transactions). This is an issue because it breaks sqlc's compilation. As best I can tell theres no configuration to prevent inserting this space.

@B4Dmonkey B4Dmonkey added the bug label Oct 14, 2024
@B4Dmonkey B4Dmonkey changed the title [FORMATTING] Issue Title Here [FORMATTING] Formatter adding space for sqlc macros Oct 14, 2024
@nene
Copy link
Collaborator

nene commented Oct 14, 2024

Thanks for reporting, but I should point out that you're using a pretty outdated version of SQL Formatter library (the latest version is 15.x). Perhaps also read the FAQ.

However this problem is also present in the latest version. There's an old issue open for this #444. So I'm closing this as duplicate.

I might suggest you instead give a try to prettier-plugin-sql-cst which does not have this issue and has in general pretty solid SQLite support.

@nene nene closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 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