DB Adapter and date formats

15 views
Skip to first unread message

Anthonin Lizé

unread,
Mar 8, 2021, 10:44:21 AM3/8/21
to Agrest Framework User Group
Hello,

I realized recently that date values provided in an exp parameter must follow the default datetime format provided by the adapter.
Examples:
Oracle: "DD-MON-YY"
Default JDBC: "YYYY-MM-DD HH:MI:SS"
Otherwise, an exception is thrown (Oracle would throw a format exception, JDBC would indicate the correct format to use).

This works with JDBC:
exp=["ptfDepl.deplDate>$d","2021-02-01 00:00:00"]

I'm fine with the JDBC one (which I use currently), but then I'm missing the specifities of the Oracle adapter, and mainly I'd love to be able to stick to the ISO format (as used in the results).
Maybe I missed something. I tried to put formatting option in the parameter via multiple methods, I can't find one working.

I'm not sure if this is more a Cayenne related question, but since it's happening only with the exp parameter I'm asking here.

I use AgRest 4.4.

Thanks in advance
Anthonin

Andrus Adamchik

unread,
Mar 9, 2021, 1:43:14 AM3/9/21
to Anthonin Lizé, Agrest Framework User Group
Hi Anthonin,

You are right - this is Cayenne-related. Cayenne doesn't do String-to-date[time] conversion of String values. So a String is passed unchanged to the JDBC driver. Cayenne users are usually not bothered by this, as they can just send an object parameter of an appropriate type (e.g. LocalDateTime). Unfortunately Agrest can only pass parameters as Strings. I just opened a task in Cayenne to implement type conversion there: https://issues.apache.org/jira/browse/CAY-2700

Thanks,
Andrus


--
You received this message because you are subscribed to the Google Groups "Agrest Framework User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agrest-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/agrest-user/0e49dfe0-90e0-40b9-ad31-8e8280e807b0n%40googlegroups.com.

Anthonin Lizé

unread,
Mar 9, 2021, 6:44:38 AM3/9/21
to Agrest Framework User Group
Thanks Andrus! It makes sense.
I'll stick to the JDBC adapter in the meantime, which is close enough to the ISO standard.

Great work by the way!
Reply all
Reply to author
Forward
0 new messages