FIX: Removed aggressive datetime parsing#235
Merged
bewithgaurav merged 2 commits intomicrosoft:mainfrom Sep 26, 2025
Merged
Conversation
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
bewithgaurav
requested changes
Sep 25, 2025
Collaborator
bewithgaurav
left a comment
There was a problem hiding this comment.
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!
bewithgaurav
previously approved these changes
Sep 26, 2025
Collaborator
bewithgaurav
left a comment
There was a problem hiding this comment.
This is great! lets fix the conflicts and we should be good to go :)
gargsaumya
previously approved these changes
Sep 26, 2025
a95c9f9
a95c9f9 to
519fc62
Compare
Contributor
Author
Should be fixed, did some messy push, but cleaned it after |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
gargsaumya
approved these changes
Sep 26, 2025
bewithgaurav
approved these changes
Sep 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):