Skip to content

Format SQL statements #6

Closed
Closed

Description

@christianguenter2
No description provided.

Activity

  1. jmgrassau commented on May 21, 2023

    @jmgrassau
    Member

    Hi Christian,

    that's of course a great idea, but also a rather complex one… So, for "expectation management", please don't expect this too be implemented too soon (at least not by me); but it is definitely on the wish list!

    Kind regards,
    Jörg-Michael

  2. self-assigned this
    on Nov 20, 2023
  3. jelliottp commented on Nov 20, 2023

    @jelliottp

    Any update on this? Is it still planned or in-progress?

    I definitely understand the complexity here. Have we considered a thin-slicing approach rather than tackling it all at once? For example, an MVP could be simply formatting with consistent indentation. Then later options for formatting the field list, aligning conditions, etc.

  4. jmgrassau commented on Nov 27, 2023

    @jmgrassau
    Member

    Hi Christian,

    thanks a lot for opening this issue and for your patience! From the SELECT statements that I saw, there were just too many coding styles to fit all required options into one cleanup rule, so I actually created three of them:

    • Align SELECT clauses aligns the keywords SELECT, FROM, FIELDS, WHERE, GROUP BY etc. in (main- or sub-)query clauses (but doesn't care for anything after the keywords), e.g.
      image
    • Align SELECT ... FROM ... JOIN aligns the FROM clause, including joins (don't worry, the cascade-style layout in the example of course not the only layout possible…), e.g.
      image
    • Align SELECT lists aligns the field lists after SELECT, FIELDS, ORDER BY, GROUP BY, and INTO ( ... ), allowing for both multi-line or single-line layout (or deriving that from the majority of elements in the list):
      image
    • Align logical expressions was enhanced to also align conditions after JOIN … ON, WHERE, HAVING, and CASE … WHEN:
      image

    And yes, you can configure the results ;-)

    • Align SELECT clauses:
      image
    • Align SELECT ... FROM ... JOIN:
      image
    • Align SELECT lists:
      image
    • Align logical expressions:
      image

    Hope this works for you!

    Kind regards,
    Jörg-Michael

  5. ConjuringCoffee commented on Nov 27, 2023

    @ConjuringCoffee
    Contributor

    Awesome! Looks great so far 👍

  6. christianguenter2 commented on Nov 27, 2023

    @christianguenter2
    Author

    Thx a lot. I'll give a try 👍

  7. kaisicker commented on Nov 27, 2023

    @kaisicker

    Thanks a lot!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions