codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.55k stars 343 forks source link

invalid timestamp data type value #841

Closed kevinjoeATdatakaveri closed 3 years ago

kevinjoeATdatakaveri commented 3 years ago

invalid timestamp data type value

tl;dr

  1. how do you create values for the SQL timestamp data type?

  2. now() doesn't work with time stamps outputs int using epochs

What happened?

Invalid value while interting a "yyyy-mm-dd hh:mm:ss.fff" value for a timestamp data type.

how to reproduce

installed immudb and immuclient from here locally on a pop_os 20.04 LTS using v.1.0.1 running a zsh shell

Issue

We need to use the timestamp data type to log time stamps in our data base. I have created a database that needs to use a timestamp using:

create table dummytable (ts timestamp, string1 varchar, string2 varchar, string3 varchar)

We (our team) have tried a few ways to insert into tables but none of them worked. Here's a screenshot of the output. We've tried

  1. insert into dummytable (ts, string1, string2, string3) values ('2021-06-18 21:38:42', 'foo', 'bar', 'baz' );
  2. insert into dummytable (timeStamp, string1, string2, string3) values ('2021-06-18 21:38:42'::timestamp, 'foo', 'bar', 'baz' );
  3. insert into dummytable (timeStamp, string1, string2, string3) values (NOW(), 'foo', 'bar', 'baz' );

We tried the above commands using psql (from the docs here) instead of immuclient as well, but it doesn't take our timestamp input. Here's a screenshot of psql output.

jeroiraz commented 3 years ago

thanks for opening the issue @kevinjoeATdatakaveri

We're still working to provide proper support for date/datetime types.

Meanwhile it's possible to deal with timestamp from the sdks by converting values into a date object in the corresponding programming language e.g. in go t := time.Unix(ts, 0) instantiates t of type time.Time, then you can manipulate it from your application e.g. fmt.Println("MM-DD-YYYY : ", t.Format("01-02-2006"))