by jakozaur · 2y ago · 0 comments
Tried this tool: go run gitlab.com/dalibo/transqlate@v0.1-beta.2
select TRUNC(SYSDATE, 'month') from dual
-- TRANSLATION ERROR at +1:8: unsupported date format: "month" rule="replace trunc() by date_trunc()" select DATE_TRUNC('month', LOCALTIMESTAMP)exit status 1
Also, at least, it would set the latest git tag, currently command from Readme.md doesn't work:
go run gitlab.com/dalibo/transqlate@latest
go: gitlab.com/dalibo/transqlate@latest: module gitlab.com/dalibo/transqlate@latest found (v0.0.0), but does not contain package gitlab.com/dalibo/transqlate
latest should point to v0.1-beta.2
Prompt:
translate the SQL statement "select TRUNC(SYSDATE, 'month') from dual" to a PostgreSQL dialect
Response (formatting removed): Here is the equivalent SQL statement in PostgreSQL for "select TRUNC(SYSDATE, 'month') from dual" in Oracle:
SELECT DATE_TRUNC('month', CURRENT_DATE) AT TIME ZONE 'UTC'
Use code with caution.
In PostgreSQL:
DATE_TRUNC is the function used to truncate a date value to a specified unit.
CURRENT_DATE is a function that returns the current date.
AT TIME ZONE 'UTC' is used to specify that the truncation should be done in Coordinated Universal Time (UTC). This is optional, but it's a good practice to be explicit about the time zone to avoid any ambiguity.
The dual table is a dummy table specific to Oracle that is used in simple SQL statements.
PostgreSQL doesn't require a table reference in this case.Hell: a friend of mine claims he asked Claude (using some plug-in in his IDE) to port his app from Firebase all the way to PostgreSQL and it just did it... and it mostly worked well enough to save him a ton of time typing and looking up syntax for stuff, and I think it is now in production?
I do agree, though--and maybe this was your core point--that maybe this "let's ask Gemini" comment should be left by someone who would also know if the answer was correct rather than just saying "no clue but". Although, honestly, even having the output seems useful here (and again: I am someone constantly unhappy about people asking questions they can Google and other such filler content).
In now interested in your friends setup. Do you have more details?
An LLM based solution can be correct but won’t be consistent.
I would much rather a tool be consistent and always incorrect in the same way than inconsistent and sometimes correct. I can create test cases and correct the underlying code. I can’t do that with an LLM
https://www.postgresql.org/docs/current/datatype-datetime.ht...
> PostgreSQL endeavors to be compatible with the SQL standard definitions for typical usage. However, the SQL standard has an odd mix of date and time types and capabilities...
> Although the date type cannot have an associated time zone, the time type can.
(emphasis mine)
> To address these difficulties, we recommend using date/time types that contain both date and time when using time zones.