Skip to content

pretty print improvements #1851

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lovasoa
Copy link
Contributor

@lovasoa lovasoa commented May 13, 2025

this is a first PR for #1850
mainly implementing pretty printing for insert update and delete statements

  • fix pretty-printing of multi-line literal strings
  • readme example for pretty printing
  • Add pretty-printing tests for various SQL statements
  • pretty print update
  • pretty-print DELETE
  • pretty-printing for INSERT statements and VALUES clause

lovasoa added 7 commits May 13, 2025 22:54
this also improves performance and simplifies pretty-printing
see apache#1850

all the tests are skipped at the moment, we will enable them as we implement more pretty printing
- Refactor DisplayCommaSeparated to accept any iterable type.
- Update indented_list to work with iterators.
- Improve formatting in the Insert display implementation
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut first = true;
for t in self.0 {
for t in self.0.clone() {
Copy link
Contributor

Choose a reason for hiding this comment

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

was the clone needed here, we seem to only call fmt on t?

Copy link
Contributor Author

@lovasoa lovasoa May 14, 2025

Choose a reason for hiding this comment

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

Yes, we are never actually cloning anything expensive here, but we need to add the Clone generic bound in order to be able to use the IntoIterator trait.

This .clone() concretely always clones

  • either just a reference (to a slice)
  • or an iterator object (but not the underlying structure being iterated on)

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.

2 participants