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

CURRENT_DATE and CURRENT_TIME should appear without brackets #809

Open
roman4e opened this issue Jul 7, 2024 · 1 comment
Open

CURRENT_DATE and CURRENT_TIME should appear without brackets #809

roman4e opened this issue Jul 7, 2024 · 1 comment

Comments

@roman4e
Copy link

roman4e commented Jul 7, 2024

In Postgresql functions CURRENT_DATE and CURRENT_TIME are keywords and appear always without brackets.

So there

class CurDate(Function):

Should be added

    def get_function_sql(self, **kwargs):                                                                               
        return "CURRENT_TIME" 

AND
there

class CurTime(Function):

should be added

    def get_function_sql(self, **kwargs):                                                                               
        return "CURRENT_TIME" 
@zburq
Copy link

zburq commented Jul 10, 2024

I had the same problem. Looks like there's an error in the docs. Here's what worked for me:

from pypika.terms import Term
class CurrentDate(Term):
    def get_sql(self, **kwargs):
        return "CURRENT_DATE"

This works too:

from pypika.terms import PseudoColumn
CurrentDate = PseudoColumn('CURRENT_DATE')

but
CurrentDate = Term('CURRENT_DATE')
didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants