Closed winterpi closed 2 years ago
I found that it's not OK for TIMESTAMP when using stdlib or generic SQL.
I debugged and found a strange problem as follow: (1). When a TIMESTAMP was inserted, it will call TimeToInt64() function in embedded/sql/timestamp.go to convert timestamp to int64, e.g. time.Now() --> 1654504712965537; (2) However, when it been saved into db, I got the value of 1654504712965537000 with sqlQuery. So it rendered error when make schema.RenderValue(1654504712965537000).
thanks for reporting this @winterpi. We'll review it asap
Sorry, it's my fault. I used the v1.3.0 go SDK, but with v1.2.1 immudb server. So the error occurred. After I changed the immudb server to V1.3.0, it's OK now.
@jeroiraz thank you for your reply.
What happened Time value parsed incorrect: "54379-11-09 02:20:17.42 +0000 UTC"
What you expected to happen Should return readable time value, such as "2022-05-30 xx:xx:xx"
How to reproduce it (as minimally and precisely as possible)
db := stdlib.OpenDB(opts)
res, err := db.ExecContext(ctx, "CREATE TABLE IF NOT EXISTS table(id INTEGER AUTO_INCREMENT, time TIMESTAMP, PRIMARY KEY id)")
rows, err := db.QueryContext(ctx, "select * from table")
var id uint64 var time time.Time rows.Next() err = rows.Scan(&id, &time) if err != nil { panic(err) } fmt.Println("id: ", id, ", time: ", time)
the result is : "id: 1 , time: 54379-11-09 02:20:17.42 +0000 UTC"
Additional info (any other context about the problem) with immudb v1.3.0