-
Notifications
You must be signed in to change notification settings - Fork 238
fix!: Add DATETIMEOFFSET handling in pyodbc for MSSQL #4930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: Add DATETIMEOFFSET handling in pyodbc for MSSQL #4930
Conversation
fe30ea2
to
a637f37
Compare
4ec0b84
to
7ed0734
Compare
@erindru hm, the tests fails when I run them on the main branch as well. |
@mattiasthalen try rebasing off of main, @themisvaltinos fixed CI. |
5affaba
to
0c169be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, @mattiasthalen.
Just double-checking, but this is backwards-compatible, yes? In the sense that DATETIMEOFFSET
would previously lead to an error, if pyodbc was used?
Yes, without it PYODBC would throw an error about data type -155 |
0c169be
to
6043490
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll mark this as breaking due to the version constraint.
a7e6a20
to
fab2de4
Compare
fab2de4
to
774b6b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks!
This ended up in a much simpler place than where we started
This pull request introduces enhancements to MSSQL connection handling, particularly for the
pyodbc
driver, and updates dependency specifications forpyodbc
across the project. The most significant changes include adding support for MSSQL'sDATETIMEOFFSET
type, improving test coverage for this feature, and ensuring thepyodbc
version is explicitly specified to avoid compatibility issues.MSSQL Connection Enhancements:
sqlmesh/core/config/connection.py
: Added support for MSSQL'sDATETIMEOFFSET
type by implementing a custom output converter at the connection level forpyodbc
. The converter handles binary data for theDATETIMEOFFSET
SQL type (-155) and converts it into Python'sdatetime
objects with timezone information.Test Coverage Improvements:
tests/core/test_connection_config.py
: Added tests to validate theDATETIMEOFFSET
handling forpyodbc
. These include scenarios for positive and negative timezone offsets, ensuring proper conversion of binary data todatetime
objects. Additionally, confirmed that_cursor_init
is no longer required forpymssql
due to the connection-level setup.Dependency Updates:
pyproject.toml
: Updated thepyodbc
dependency to require version>=5.0.0
across multiple optional dependency groups (azuresql-odbc
,mssql-odbc
, anddev
) to ensure compatibility with the new features. [1] [2] [3]