Extended SQL Options (like GROUP BY and HAVING) Similar to Mojo::PG and Sorting?
ViktorNacht opened this issue · comments
Does Mojo::mysql support the extra (non-PostgreSQL specific) options as documented here for Mojo::PG?
https://mojolicious.org/perldoc/Mojo/Pg/Database#select
Also, I wanted to suggest that it might be nice to document or show any example in the docs on specifying a sort order in the select method. I know you can click over the SQL::Abtract docs to figure it out, but for new users it might be helpful.
You need to use SQL::Abstract::Pg instead of SQL::Abstract to get all of the options indicated that way. You can set it as the 'abstract' attribute of Mojo::mysql. No guarantees as to what features will work in mysql.
@Grinnz: Is the dialect the same?
@ViktorNacht: I'm not entirely sure how to go about this, but if you open a PR with something like https://github.com/mojolicious/mojo-pg/blob/master/lib/SQL/Abstract/Pg.pm then I will probably take it...
When that is said, I thought these features was already implemented.
@Grinnz Thank you very much. Solutions like this really make me appreciate the Mojo ecosystem.
@jhthorsen For sure. I would like to contribute and will look into the code, but I confess I still live with the handicap of a 22-year CGI.pm mindset, lol.
Does it make sense to include SQL::Abstract::Pg and turn some of the options like 'on_conflct' into noops, or do you think manually crafting it would be required? Just considering future maintenance.
Hope you don't mind if I enter the discussion.
@ViktorNacht you could fork this repo, then we could take a closer look at it and come back here with a solution.
Sure, I've forked it. I think these extensions really make the module much more powerful.
Here is a first PR: #46
JSON from SQL::Abstract::Pg is missing for the moment, I plan to add some high-level JSON support (whatever this means).
I'm closing this in favour of #46.
@ViktorNacht: Please comment on the PR if it does not do what you want.