-
Notifications
You must be signed in to change notification settings - Fork 27
FIX: Removed aggressive datetime parsing #235
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: Removed aggressive datetime parsing #235
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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 is a significant fix.. Have added one comment related to tests, please make changes and we can merge this off for our next release :)
Thanks for your efforts!
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 is great! lets fix the conflicts and we should be good to go :)
a95c9f9
a95c9f9 to
519fc62
Compare
Should be fixed, did some messy push, but cleaned it after |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Work Item / Issue Reference
Summary
Summary
This PR fixes a critical issue where string parameters were being automatically converted to datetime objects, causing failures in SQL queries that require string-to-string comparisons. The fix removes aggressive content-based datetime parsing from the
_map_sql_type()method while preserving all existing functionality for actual datetime objects.Problem
The mssql-python driver was failing on queries like:
This would throw datetime conversion errors because the driver was automatically trying to parse the string
'2025-08-12'as a date object, even when it should remain a string for the RIGHT() function comparison.Problematic Code (Before Fix):
Why This Was Wrong:
Solution
Approach: Follow PyMSSQL's proven type-based parameter mapping approach.
Key Changes:
_map_sql_type()for string parametersFiles Modified:
mssql_python/cursor.py: Simplified string parameter handling in_map_sql_type()tests/test_004_cursor.py: Added test for string parameter behaviorBefore vs After
Before (Failed):
After (Works):