-
Notifications
You must be signed in to change notification settings - Fork 18
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
Thank you — and reusable SQL formatting #20
Comments
You're welcome :)
Well, the current implementation is far from being perfect. It derives database-level types from Elixir types as Ecto telemetry events do not provide params types. If you need |
I’m looking at SQL formatting from a library perspective because of the need to capture migration SQL. Where extracting an SQL formatter might be useful (IMO) is that it would hopefully attract other contributors who would be able to extend it to behave correctly in more cases. As of right now, my implementation's correctness is probably even less than yours:
|
Having a dedicated library for formatting parameters is a good idea. But for the time being, I'd suggest just using |
The biggest "issue" with using the provided formatter by default is that for some cases, I wouldn’t want the ANSI escape codes (again, see my initial use case). Like I said, my main thought here was that this might be a useful direction for the future. It’s not an immediate need now. |
I think that my needs for SQL formatting could be achieved if there were a way to call EctoDevLogger's SQL formatter code to suppress colouring. |
|
I think it is better to make |
I’ve implemented something like the formatter bits of ecto_dev_logger in the past, but your approach here was very clean and helped me with an investigation that I was looking for.
I have suggested to the Ecto team that Ecto (SQL) probably should have formatter functions and callbacks to the adapters for the differences as you have implemented, and that your formatter code might be a really good start for this.
If that's rejected, can I suggest extracting the SQL formatter code from ecto_dev_logger into a separate repository/package so that it is usable by others? We’ve written an
inspect_sql
function that has similar formatting functionality (focused only on PostgreSQL for now), but I think that if the Ecto team doesn’t have any interest in a formatter by default, having a community package focused on formatting would be the next best option.The text was updated successfully, but these errors were encountered: