Pretty print for Statement
See original GitHub issueit would be great if Statement had a
String prettyPrint(int width)
method, which formats the resulting String into a maximum width.
It would make it much nicer to display to end-users.
Or something similar, like
SELECT ...
FROM ...
WHERE ...
with predefined line breaks.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Prettify Your Data Structures With Pretty Print in Python
The pprint module, Python's data pretty printer, is a useful part of the standard library. You can work with it for debugging data...
Read more >pprint — Data pretty printer — Python 3.11.1 documentation
The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the...
Read more >Java-Code/Statement1PrettyPrint1.java at master - GitHub
Layered implementation of secondary method {@code prettyPrint} for ... Constructs into the given {@code Statement} the BLOCK statement read from.
Read more >How to Use Pretty Print Module in Python - Linux Hint
Pretty Print Module is used to produce formatted output in Python. ... The last statement prints the output of the pretty variable.
Read more >12.8 Pretty Printing - Brown CS
Pretty -prints the value v using the same printed form as write, but with newlines and whitespace inserted to avoid lines longer than...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@stewartbryson, I didn’t try to import it directly from hibernate actually, as I needed to apply a few small changes to the hibernate formatter, so we just copied the source code of the file to our codebase, from: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java
Once I had that class, I can just import the class BasicFormatterImpl and call: String formattedSQL = new BasicFormatterImpl().format(sql);
Have a look at JSQLFormatter, which is using JSQLParser for understanding the AST of a SQL statement. Plenty of samples here: http://217.160.215.75:8080/jsqlformatter/samples.html and you can test it online and interactively here
Disclaimer: I am the author of this software.