arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

Conversion from DateTime to Long in prepared statements

Open vic0824 opened this issue 1 year ago • 4 comments

ArcadeDB Version:

ArcadeDB Server v24.2.1 (build https://github.com/ArcadeData/arcadedb/commit/ce2658d9f43625df903d593f39604003b0512bd5/1710272693676/main)

OS and JDK Version:

Linux 2.6.32-754.35.1.el6.x86_64 - OpenJDK 64-Bit Server VM 11.0.22 (Corretto-11.0.22.7.1)

Expected behavior

It is possible to use the asLong() function to convert a DateTime positional parameter in a prepared statement

Actual behavior

The conversion does not work, it looks like it always returns null

Steps to reproduce

Execute the attached testDateTimeMicrosToLongConversion test case

testDateTimeMicrosToLongConversion.zip

vic0824 avatar Apr 15 '24 07:04 vic0824

The conversion to long is supported. Have you tried with the latest version? We updated the automatic conversion in the latest release.

lvca avatar Apr 15 '24 14:04 lvca

I'm using v24.2.1, which is the latest version. I did some more tests and I have found that the issue is related to the use of aliases. This select works: SELECT name, start, stop, dist FROM (SELECT name, type, start, stop, v, abs(?.asLong() - stop.asLong()) as dist FROM Product where type = 'SIR1LRC11B') ORDER BY dist ASC, v DESC limit 1 while this one fails: SELECT name, start, stop, dist FROM (SELECT name, type, start, stop, v, ? as centerInterval, abs(centerInterval.asLong() - stop.asLong()) as dist FROM Product where type = 'SIR1LRC11B') ORDER BY dist ASC, v DESC limit 1

vic0824 avatar Apr 17 '24 09:04 vic0824

@vic0824 what's the error? It just return null? Can you display the value of the property that can't be converted into long?

lvca avatar May 24 '24 09:05 lvca

It returns an incorrect record. Basically, if I create an alias for a positional parameter, the asLong() function produces an incorrect result. If I use ?.asLong() directly it works. I have created the attached test case to demonstrate it.

testRecentValidityClosest.zip

vic0824 avatar May 24 '24 13:05 vic0824