Replies: 1 comment
-
|
Hey @ds-cbo, you would need to create a new Then, you make sure it roundtrips unaffected in MySQL and finally add a generator for it in Postgres to produce the equivalent SQL. I think your example should just work after that, perhaps with a slight tweak of the Closing this one but feel free to reach out in our Slack for easier communication |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am translating a bunch of MySQL queries we have to PostgreSQL and so far this tool seems to do everything perfectly, but there's one warning which results a mismatch which I'd like to work on fixing.
For example, in MySQL we have:
In human language that comes down to "get the first day of the week of 'date'" (assuming weeks start on monday).
Converting this manually to PostgreSQL, I can only come up with
Because where MySQL's weekday starts with monday=0, PostgreSQL's extract starts DOW with sunday=0.
Test cases
How would one go on to generalise this approach? Currently it gets stuck on
sqlglot/sqlglot/dialects/postgres.py
Lines 69 to 75 in a9d0f63
making the current output:
with token tree
I would be okay with adding support just for the
weekdaycase, but I'm new to this codebase and don't quite know where to start. I imagine it'd first need to understand theWEEKDAYfunction of MySQL to parse it into a proper non-Anonymous structure. Or would it be okay to add something liketo patch specific support into it?
I read through the documentation but couldn't find a good starting point, so I'm looking for tips here.
Beta Was this translation helpful? Give feedback.
All reactions