fix(sql_database): reflect timestamp/datetime precision at full_with_precision - #4342
Open
Aryan-Pardeshi wants to merge 1 commit into
Open
fix(sql_database): reflect timestamp/datetime precision at full_with_precision#4342Aryan-Pardeshi wants to merge 1 commit into
Aryan-Pardeshi wants to merge 1 commit into
Conversation
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.
Fixes #4316
Problem
sqla_col_to_column_schemanever reads.precisionfromDateTimetypes, so timestamp/datetime columns lose their fractional-seconds precision even atreflection_level="full_with_precision"(the level explicitly gated byadd_precision). OnlyNumeric,SmallInteger,String, and_Binaryhad precision handling.Change
In the
DateTimebranch, whenadd_precisionis set and the reflected type exposes aprecisionattribute (e.g. OracleTIMESTAMP(p), MSSQLDATETIME2(p)), emitcol["precision"]. Guarded withgetattrsince genericsa.DateTimehas no such attribute.Tests
test_timestamp_precision_reflected_full_with_precision—DATETIME2(3)→precision: 3atfull_with_precisiontest_timestamp_precision_omitted_without_full_with_precision— no precision key at"full"test_generic_datetime_has_no_precision_key— genericDateTimeemits no precision keyVerified:
tests/sources/sql_database/test_schema_types.py— 20 passed under SQLAlchemy 2.0.51 and 2.1.0b3.