Skip to content
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

Recognize special functions and emit the equivalent (more standard?) construct #2

Closed
lelit opened this issue Aug 9, 2017 · 2 comments
Closed

Comments

@lelit
Copy link
Owner

@lelit lelit commented Aug 9, 2017

Take for example the query

SELECT * FROM manufacturers
ORDER BY EXTRACT('year' FROM deliver_date) ASC,
         EXTRACT('month' FROM deliver_date) ASC,
         EXTRACT('day' FROM deliver_date) ASC

is currently rendered as

SELECT *
FROM manufacturers
ORDER BY pg_catalog.date_part('year'
                            , deliver_date) ASC
       , pg_catalog.date_part('month'
                            , deliver_date) ASC
       , pg_catalog.date_part('day'
                            , deliver_date) ASC

because that's how the EXTRACT function is remapped by the parser.

It would be nice to optionally have a way to recognize those functions and map them back to more verbose form.

@lelit lelit changed the title Recognize special functions and emit the equivalent a more standard (?) construct Recognize special functions and emit the equivalent (more standard?) construct Aug 9, 2017
@lelit

This comment has been minimized.

Copy link
Owner Author

@lelit lelit commented Aug 9, 2017

Another example:

SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS
       (DATE '2001-10-30', DATE '2002-10-30')

becomes

SELECT pg_catalog.overlaps('2001-02-16'::date
                         , '2001-12-21'::date
                         , '2001-10-30'::date
                         , '2002-10-30'::date)
lelit added a commit that referenced this issue Nov 22, 2017
@lelit

This comment has been minimized.

Copy link
Owner Author

@lelit lelit commented Nov 22, 2017

Now there is a reasonably simple machinery to install such diversions, and the cases above are already covered, albeit inactive by default.

@lelit lelit closed this Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.