alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

odbc driver not parsing microseconds for time(7) column type #118

Closed Omortis closed 6 years ago

Omortis commented 6 years ago

This is sort of related to 102 maybe?

The odbc driver doesn't seem to be handling the microseconds correctly. For a time(7) value of:

14:28:44.712000000

the odbc driver is returning:

14:28:44-05:00

In fact, all microsecond values returned are "-05:00"

Could this be because I am scanning into a string?

var messageTime string
err = rows.Scan(&messageTime)

Any suggestions?

alexbrainman commented 6 years ago

My 766c1869ce217ccf49f283a96efc4dc89c5e4075 change reads SQL_SS_TIME2 SQL types into SQL_TIME_STRUCT. And SQL_TIME_STRUCT only provides seconds - no milliseconds or less. So I am surprised you are talking about microseconds - I would not expect anything less than seconds.

Looking at https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-date-time/data-type-support-for-odbc-date-and-time-improvements?view=sql-server-2017 maybe we could use SQL_SS_TIME2_STRUCT instead.

It would be very helpful for me if you could give me a small Go program that demonstrates your problem. It would have to contain a SQL that triggers this issue.

I will wait for your example, before spending any more time on this issue.

Thank you.

Alex

Omortis commented 6 years ago

@alexbrainman I'm used to talking in microseconds at my day job - meaning anything to the right of the decimal... ;-) I will put together some sample code this weekend or very early on Monday morning and post it here.

alexbrainman commented 6 years ago

I will put together some sample code this weekend or very early on Monday morning and post it here.

When you are free. No rush.

Alex

Omortis commented 6 years ago

@alexbrainman actually I looked back at my prior issue 102 and if you look at my last post, using the sample code I posted (and which you used to recreate the issue) the "missing microseconds" values are already not there. I think you can use that same code to re-create it? Do you need more than that?

I never noticed it then, surprisingly.

alexbrainman commented 6 years ago

@Omortis I just submitted fix for this issue. Please reopen if you think the issue still exist.

Thank you.

Alex

Omortis commented 6 years ago

@alexbrainman Looks good - thanks!

> gotest.exe
Connection ok!
0001-01-01 11:58:46.957 -0500 EST Value #1
0001-01-01 14:10:47.895 -0500 EST Value #2
0001-01-01 14:43:35.927 -0500 EST Value #3