Skip to content

Conversation

@swt30
Copy link
Contributor

@swt30 swt30 commented Nov 7, 2025

sqlfmt appends another newline to stdout when formatting text from stdin (as well as the newline added by the formatter).

This means that formatting outputs are inconsistent between the following methods:

  • pass file contents to sqlfmt stdin, format, overwrite file
  • sqlfmt file directly

This change removes the extra newline. It changes one test which assumed the existence of the extra newline, but I think this new behaviour makes more sense.

Fixes #729

Copy link
Owner

@tconbeer tconbeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you. Just needs a CHANGELOG entry

@swt30 swt30 force-pushed the omit-newline-stdout branch 2 times, most recently from 816ed66 to a2c126f Compare November 19, 2025 13:15
@swt30
Copy link
Contributor Author

swt30 commented Nov 19, 2025

There you go :) I guess this is technically a breaking change. Up to you to decide how you want to bump the version for release.

@tconbeer
Copy link
Owner

No, this is fine. same as the tests you already changed. Just fix the tests, please

@swt30
Copy link
Contributor Author

swt30 commented Nov 19, 2025

Oh I see what you mean, there are extra end-to-end tests. I had only run make unit and missed the full suite.

@swt30 swt30 force-pushed the omit-newline-stdout branch from a2c126f to ae6d184 Compare November 19, 2025 17:33
@swt30
Copy link
Contributor Author

swt30 commented Nov 19, 2025

All tests pass on my end 👍

@swt30 swt30 force-pushed the omit-newline-stdout branch from ae6d184 to 9d868a0 Compare November 19, 2025 17:35
@swt30 swt30 changed the title Omit extra newline when outputting to stdout Omit extra newline when printing to stdout Nov 19, 2025
@swt30 swt30 force-pushed the omit-newline-stdout branch from 9d868a0 to ddf760a Compare November 20, 2025 12:09
@swt30
Copy link
Contributor Author

swt30 commented Nov 20, 2025

... and fix linter errors (sorry, I had missed there was a linter check too)

@tconbeer tconbeer merged commit e77cd69 into tconbeer:main Dec 21, 2025
20 checks passed
@swt30
Copy link
Contributor Author

swt30 commented Dec 22, 2025

Thanks, sorry about accidentally including the coverage file, that was messy of me

@tconbeer
Copy link
Owner

No worries! Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra newline in output to stdout

2 participants