Glrp misses DATE and TIME Prefix functions

14 views
Skip to first unread message

Joachim Tuchel

unread,
Nov 7, 2023, 10:04:37 AM11/7/23
to glorp...@googlegroups.com

Hi again,


seems I am in the flow for sending out Glorp fixes.

During my experiments to find out under which circumstances certain alsoFetch:ed objects aren't registered, I tried to extend my test case I just posted here today. I wanted to add a query that ends up as


SELECT ... FROM .. WHERE ... AND DATE(TIMESTAMP) > someOtherDate


So I tried something like

Query read: LogEntry where: [:entry | entry timestamp time >= currentTimeMinus30Seconds].


... and guess what: Glorp has no definitition for the SQL functions DATE() and TIME() and throws an error because it has no mapping for #time...

The fix is easy. Afaik, all SQL databases support DATE() and TIME(), so we can add these function to the set of basic functions in FunctionExpression class>>#createBasicFunctionsFor:

Just add these lines to FunctionExpression class>>#createBasicFunctionsFor:


    defaultFunctions
        at: #date put: ((PrefixFunction named: 'DATE') type: aDatabasePlatform date);
        at: #time put: ((PrefixFunction named: 'TIME') type: aDatabasePlatform time).


right before
   ^defaultFunctions


That's it.


Joachim








Esteban Maringolo

unread,
Nov 8, 2023, 8:50:47 AM11/8/23
to glorp...@googlegroups.com
Hi Joachim,

The DATE() and TIME() functions are not supported by all database engines, actually only DB2 supports both, PostgreSQL only supports DATE() and Oracle, SQLite support none (SQLite doesn't even have a DATE or TIME column type).

So we could add this to DB2Platform, but it is not that all databases support them.

Best regards,

Esteban A. Maringolo


--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glorp-group...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/ee8df3fd-7d8c-41f5-a6b3-0d316cbb29d3%40objektfabrik.de.

jtuchel

unread,
Nov 8, 2023, 9:59:27 AM11/8/23
to glorp-group
Thanks Esteban, I completely missed that SQLite doesn't have date/time/timestamp datatypes. I have used timestamps with sqlite and glorp before and had no issues, I just found out after your message that Glorp hides the fact from users.

So the functions belong to DB2Platform>>initializeFunctions, and not into the list of generic functions.

Joachim
Reply all
Reply to author
Forward
0 new messages