Add Oracle import - #1440
Merged
Merged
Conversation
Create a data contract from a live Oracle database with `datacontract import oracle`, replacing a recipe that told users to pull the DDL out of DBMS_METADATA, import the file, and then fill in a placeholder servers block by hand. Oracle reports a DATA_LENGTH for every column, but it only belongs to the declared type for character and raw types, so a DATE would otherwise become DATE(7). The rule that the test path already applied when reading this catalog back is now shared with the import rather than duplicated. Catalog numbers arrive as Decimal, which YAML writes as a Python-specific tag; they are coerced to int so the contract stays readable by other tools.
📖 Docs previewPreview site: https://brave-water-0cee36e03-1440.westeurope.7.azurestaticapps.net Changed pages (most-changed first):
|
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.
Summary
Adds
datacontract import oracle, which creates a data contract from a live Oracle database:The guide previously told users to pull the DDL out of
DBMS_METADATA.GET_DDL, import the file withimport sql --dialect oracle, and then fill in aserversblock of placeholder values.The length rule is shared, not duplicated. Oracle reports a
DATA_LENGTHfor every column, but it is only part of the declared type for character and raw types — otherwise aDATE(length 7) would becomeDATE(7)and aCLOB(length 4000)CLOB(4000), neither of which matches what the test path reads back. That rule already existed insidenative_type._map_reconstructed; it is now a named function both paths call.--schemais upper-cased, since Oracle stores identifiers that way and a lower-case owner matches nothing.Verified against a real Oracle
Import followed by
datacontract teston the unedited file: 16/16 checks passed. The catalog for the seeded table shows why the length rule matters:A bug only the real run could find: Oracle returns catalog numbers as
Decimal, and the first contract came out with— a Python-specific YAML tag that no other tool can read and
yaml.safe_loadrejects. They are coerced toint, and a test asserts no!!pythontag appears in the output.Testing
tests/test_import_oracle.py— 10 tests. The seven that need a database are markedslow, matchingtest_test_oracle_xe.py, so they run in the dedicated CI job rather than on every invocation; the three argument-validation tests need no container. All ten pass locally againstgvenzl/oracle-xe:21-slim-faststart, and the existing Oracle suite still passes.Docs
New
imports/oracle.md;testing/oracle.mdgets the one-command step 3 with theDBMS_METADATArecipe reduced to a fallback, and step 2 renamed to "Authenticate" for consistency.