Closed docbacardi closed 1 year ago
Looks like I stumbled over 2 problems. The first one is using the SQL function date()
without a time component. This is suggested by the example from here:
SELECT FROM Account WHERE created <= date('2012-07-02', 'yyyy-MM-dd')
While a complete date + time works, just a date throws the exception Unable to obtain LocalTime from TemporalAccessor
:
testdatabase=> SELECT date('2012-07-02 10:03:21');
date('2012-07-02 10:03:21')
-------------------------------
Mon Jul 02 12:03:21 CEST 2012
(1 row)
testdatabase=> SELECT date('2012-07-02');
ERROR: Error on executing query: Text '2012-07-02' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO,Europe/Berlin resolved to 2012-07-02 of type java.time.format.Parsed
testdatabase=> SELECT date('2012-07-02', 'yyyy-MM-dd');
ERROR: Error on executing query: Text '2012-07-02' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO,Europe/Berlin resolved to 2012-07-02 of type java.time.format.Parsed
This could be fixed by providing defaults for the time fields, like #1256 does.
The second problem are missing error messages for an invalid date format like this:
testdatabase=> SELECT date("Wed Sep 06 16:35:27 CEST 2023");
--
(1 row)
Currently a null
is returned.
Thanks @docbacardi for the PR!
ArcadeDB Version:
ArcadeDB Server v23.9.1-SNAPSHOT (build 54c7e798b004f5d80e9fe5e3ce4afd7d89e50aea/1693919158748/main)
OS and JDK Version:
Running on Linux 5.15.0-78-generic - OpenJDK 64-Bit Server VM 11.0.20.1
Expected behavior
The SQL command "date()" should create a date object as described here: https://docs.arcadedb.com/#_date .
Actual behavior
The "date()" function returns
null
or throws an exception.Steps to reproduce
All commands were tested in the studio and with a psql client. The examples here show only the psql output. Running the commands in the studio gives the same results.
The function "sysdate()" works as expected:
The function "date()" throws an exception. This is based on the example shown here: https://docs.arcadedb.com/#_date
And in the server logs:
Trying a different format gives a
null
result (which is only visible in the studio as<null>
):