Skip to content

[feature] allow pretty-printing #1845

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
lovasoa opened this issue May 8, 2025 · 2 comments · Fixed by #1847
Closed

[feature] allow pretty-printing #1845

lovasoa opened this issue May 8, 2025 · 2 comments · Fixed by #1847

Comments

@lovasoa
Copy link
Contributor

lovasoa commented May 8, 2025

In rust, the Display trait allows specifying an "alternate" display style for every type:

https://doc.rust-lang.org/std/fmt/struct.Formatter.html#method.alternate

I suggest using this to allow "pretty-printing" SQL statements, including newlines.

Currently, long queries printed by sqlparser are hardly human-readable, since they are displayed as a single long line of text. We could allow displaying them with newlines between keywords and expressions when they are printed with {:#}

this is also a potential more feasible alternative to #1634

I could implement this myself.

What do you think, @alamb , @iffyio ?

@alamb
Copy link
Contributor

alamb commented May 9, 2025

If the idea is that {:#} printing of AST nodes would result in printing a "pretty" version of the sql statements (potentially with newlines, etc) sounds like a great idea to me

lovasoa added a commit to lovasoa/sqlparser-rs that referenced this issue May 9, 2025
@lovasoa
Copy link
Contributor Author

lovasoa commented May 13, 2025

follow-up tracking issue in #1850

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 a pull request may close this issue.

2 participants