Fix physicalType accessibility in sql_type_converter#1052
Open
jochenchrist wants to merge 2 commits intomainfrom
Open
Fix physicalType accessibility in sql_type_converter#1052jochenchrist wants to merge 2 commits intomainfrom
jochenchrist wants to merge 2 commits intomainfrom
Conversation
…#1039) The convert_to_sql_type() function was not properly accessing the physicalType attribute on ODCS SchemaProperty objects. SchemaProperty stores physicalType as a first-class attribute, not in customProperties, so the _get_config_value() lookup always returned None. Changes: - convert_to_sql_type(): Now checks SchemaProperty.physicalType directly as a passthrough when logicalType is not set (indicating a user-specified native SQL type like "TIMESTAMP(6)" or "VARCHAR(255)") - convert_type_to_oracle(): Updated to accept Union[SchemaProperty, FieldLike], added oracleType customProperty override support, and properly handles both ODCS and DCS field types - Added comprehensive tests covering physicalType passthrough, logical type fallback, Oracle type handling, and server-specific overrides https://claude.ai/code/session_01LzYDYYGTpu2vfaGjApwR9i
Keep generalized Union[SchemaProperty, FieldLike] signature consistent with all other converters in the file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Description
Fixes issue #1039 by properly handling
SchemaProperty.physicalTypein the SQL type conversion logic.Changes
datacontract/export/sql_type_converter.py:
_get_type()to document the preference forphysicalTypewhen available, as it carries more precision informationconvert_to_sql_type()to correctly handlephysicalTypefromSchemaProperty:physicalTypeis set (nologicalType), it's treated as a direct SQL type passthrough (e.g., user-specified native types like "TIMESTAMP(6)", "VARCHAR(255)")physicalTypedrives server-specific type mapping (preserving precision like "int" vs "long")customProperties["physicalType"]overridesconvert_type_to_oracle()to:SchemaPropertyandFieldLikefor consistencyphysicalTypedirectly for native Oracle types when setcustomProperties["oracleType"]overrideslogicalTypemapping whenphysicalTypeis not availabletests/test_sql_type_converter_physicaltype.py (new):
physicalTypewhenlogicalTypeis absentphysicalTypeandlogicalTypeare setlogicalTypewhenphysicalTypeis not setTest Coverage
All new functionality is covered by the added test suite:
TestPhysicalTypeDirectPassthrough: 4 testsTestPhysicalTypeWithLogicalType: 5 testsTestLogicalTypeFallback: 4 testsTestConvertTypeToOracle: 6 testsTestServerSpecificOverrides: 3 testsTests pass
ruff format
README.md updated (if relevant)
CHANGELOG.md entry added
https://claude.ai/code/session_01LzYDYYGTpu2vfaGjApwR9i