findmypast-oss / mssqlex

Microsoft SQL Server Adapter for Elixir
Apache License 2.0
41 stars 22 forks source link

Support for datetimeoffset? #7

Open fpauser opened 7 years ago

fpauser commented 7 years ago

Querying a table with a datetimeoffset field gives an error: 'Column type not supported'. Also tested directly with :odbc, error persists:

{:ok, pid} = :odbc.connect(connect_string, [])
{:ok, #PID<0.221.0>}
:odbc.sql_query(pid, 'select date_in from test_table')     
{:error, 'Column type not supported'}

Is it really :odbc.sql_query that does not support datetimeoffset?

shdblowers commented 7 years ago

Thanks for bringing this to our attention @fpauser. We will investigate further, but I would not be surprised if this column type is not supported by the Erlang ODBC library.

More about datetimeoffset:

Defines a date that is combined with a time of a day that has time zone awareness and is based on a 24-hour clock.

More info on the type on Microsoft Docs.

fpauser commented 7 years ago

Seems like odbc-support for current sqlserver features is quite limited. Not being able to query datetimeoffset columns is a showstopper for me.

jbachhardie commented 7 years ago

Yeah, the Erland ODBC application has very limited support for non-standard column types. You would need to either patch Erlang OTP or write your own driver to use instead of ODBC. The latter is what https://github.com/livehelpnow/tds tried but that project hasn't been maintained in a long time, which speaks to the complexity of the task.

We unfortunately have no plans to undertake either of these pieces of work but we'll gladly cooperate with anyone who is willing to do so.

shdblowers commented 7 years ago

I have opened up this issue on the Erlang/OTP bug board. Will try and fix it myself hopefully with a bit of guidance from the OTP maintainers.

shdblowers commented 7 years ago

C Data Type Struct for datetimeoffset: https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-date-time/data-type-support-for-odbc-date-and-time-improvements

ker2x commented 3 years ago

hi, i just stumbled upon this issue. FIY, datetimeoffset not supported on python odbc driver either so it's probably not erlang specific :)