codenotary / immudb-node

Node.js SDK for immudb
Apache License 2.0
62 stars 2 forks source link

undefined value for TIMESTAMP field on SELECT #24

Closed zgalili closed 1 year ago

zgalili commented 2 years ago

Hi :)

I have a TIMESTAMP field called created_at in our db. To populate that field I use CAST(@created_at AS TIMESTAMP) (or NOW()) in the INSERT process.

When querying in the immuclient I can see the data in that field, it looks like that: 2022-06-23 09:04:37 (its not surrounded by " like VARCHAR fields)

But I can't find a way to get the data in Node, When using SELECT * or SELECT created_at the value I get back is undefined (for other fields I do get the data, all of them are VARCHAR fields except the id which is INTEGER)

I've tried to use: select CAST(created_at AS VARCHAR) and got SQLQuery error Error: 2 UNKNOWN: syntax error: unexpected CAST CONVERT(VARCHAR, created_at) and select STR(created_at,10) and got SQLQuery error Error: 2 UNKNOWN: syntax error: unexpected '(',

What is the correct way to get the TIMESTAMP data back from the db?

If this question is not considered as an issue and doesn't belong here, sorry! just point me to the correct place to post this please :)

Thanks a lot, Ziv.

jeroiraz commented 2 years ago

thanks a lot for reporting it @zgalili

it seems node sdk is not handling the TIMESTAMP data type

for each row a SQLRowDescription is built at this line: https://github.com/codenotary/immudb-node/blob/6c637cdf358d069fc3aa41cfb0a32f0adab4d53b/src/client.ts#L1709

The value can be any of:

message SQLValue {
    oneof value {
        google.protobuf.NullValue null = 1;
        int64 n = 2;
        string s = 3;
        bool b = 4;
        bytes bs = 5;
        int64 ts = 6;
    }
}

It'd be super if you can figure it out how to include the TIMESTAMP support there, otherwise we'll be solving asap

tomekkolo commented 1 year ago

closing as immudb-node was updated to v2