K2InformaticsGmbH / erloci

Erlang Oracle native driver - DEPRECATED, see https://github.com/K2InformaticsGmbH/oranif instead
Apache License 2.0
37 stars 11 forks source link

Timestamp fractional seconds internal oracle representation. #66

Open acautin opened 6 years ago

acautin commented 6 years ago

Hi I am seeing wrong results when using oci_util:from_dts/1 function for the fractional part. The problem seems to be matching using little endian instead of big when decoding the value.

Also #5 doesn't seem to be correct as I can read the data in binary format.

c-bik commented 6 years ago

@acautin

In https://github.com/K2InformaticsGmbH/erloci/blob/480fe1388ee377e5be869155945762637f6dd3ad/src/oci_util.erl#L287 and https://github.com/K2InformaticsGmbH/erloci/blob/480fe1388ee377e5be869155945762637f6dd3ad/src/oci_util.erl#L295 ...is it giving you correct result if you replace Ns:4/little-unsigned-integer-unit:8 with Ns:4/big-unsigned-integer-unit:8

c-bik commented 6 years ago

5 is an old a bug, it probably doesn't apply any more. I will try to verify and close that later!

👍 for find it!

c-bik commented 6 years ago

Also need to update this test case with better verification for correctness of API https://github.com/K2InformaticsGmbH/erloci/blob/480fe1388ee377e5be869155945762637f6dd3ad/test/erloci_test.erl#L963-L966 Currently API correctness isn't checked.

acautin commented 6 years ago

For the fractional part (Which was what I was interested at the moment) yes it gives me the correct results if I use big there. For now I am using only the datetime conversion taking the first 7 bytes and adding the fraction (if there is any) myself. We can replace it later when this is fixed. https://github.com/K2InformaticsGmbH/dderl/blob/master/src/dderloci_utils.erl#L142-L146

c-bik commented 6 years ago

This will deprecate most of oci_util APIs

For example: image