Closed pnezis closed 1 month ago
That would be a really cool use case (and one that I didn't think about)! Definitely would be interested in merging this one when you button it up.
I have also used pgformatter in the past as well.....but it is much slower given that it is written in perl and also chokes on very large queries.
@akoutmos ready
This hit me just as I was reviewing the code. How about instead of copying in the mix format
mix task we instead make this a mix format plugin? https://hexdocs.pm/mix/main/Mix.Tasks.Format.html#module-plugins
That way we lean on the existing mix tooling and --check-formatted
will work just the same. That and we can also create a ~SQL """...""" sigil for formatting SQL statements which would be quite handy in migrations. I always hate manually formatting SQL statements in migrations and a sigil would tie in nicely with the mix format plugin.
Thoughts?
I like it, new PR coming soon. My only concern with the ~SQL
sigil is that it will make :sql_fmt
a required prod dependency as well, I planned to have it only as :dev
, but this is minor.
Closing in favour of #3
Similar to
mix format
but for SQL queries 😄 .The code is mostly "stolen" from
mix format
. We already usepgformatter
in our CI pipelines, we could replace it with this.If you are ok with adding the mix task, I will add tests and CLI flags for the supported formatting options.