]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Oracle dialect reflection of RAW length
authorDaniel Sullivan <daniel.j.sullivan@state.mn.us>
Tue, 3 Mar 2026 20:50:17 +0000 (15:50 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 3 Mar 2026 20:58:08 +0000 (15:58 -0500)
Fixed issue in Oracle dialect where the :class:`_oracle.RAW` datatype would
not reflect the length parameter.   Pull request courtesy Daniel Sullivan.

Fixes: #13150
Closes: #13149
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13149
Pull-request-sha: f7488faaf86451dfe53801faa848414c343614b3

Change-Id: I7db0219b6484317de15203b42f9ca5a84fe36bb7

doc/build/changelog/unreleased_20/13150.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py
test/dialect/oracle/test_reflection.py

diff --git a/doc/build/changelog/unreleased_20/13150.rst b/doc/build/changelog/unreleased_20/13150.rst
new file mode 100644 (file)
index 0000000..2466575
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, oracle
+    :tickets: 13150
+
+    Fixed issue in Oracle dialect where the :class:`_oracle.RAW` datatype would
+    not reflect the length parameter.   Pull request courtesy Daniel Sullivan.
+
index f228041c0e46b3d4e030bd00fa25c07744116b9e..937df0d23f3c8f51faf6be7294cc3b97eb4111d1 100644 (file)
@@ -2847,6 +2847,7 @@ class OracleDialect(default.DefaultDialect):
                 all_cols.c.column_name,
                 all_cols.c.data_type,
                 all_cols.c.char_length,
+                all_cols.c.data_length,
                 all_cols.c.data_precision,
                 all_cols.c.data_scale,
                 all_cols.c.nullable,
@@ -2965,6 +2966,9 @@ class OracleDialect(default.DefaultDialect):
             elif coltype in ("VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR"):
                 char_length = maybe_int(row_dict["char_length"])
                 coltype = self.ischema_names.get(coltype)(char_length)
+            elif coltype == "RAW":
+                data_length = maybe_int(row_dict["data_length"])
+                coltype = RAW(data_length)
             elif "WITH TIME ZONE" in coltype:
                 coltype = TIMESTAMP(timezone=True)
             elif "WITH LOCAL TIME ZONE" in coltype:
index 3f363dafeeeb8941fc3053b39db5874051983a0b..265857e01398d401a0a1f3700c8a387beef859a4 100644 (file)
@@ -1384,16 +1384,16 @@ class TypeReflectionTest(fixtures.TestBase):
         ]
         self._run_test(metadata, connection, specs, ["length"])
 
-    @testing.combinations(ROWID(), RAW(1), argnames="type_")
-    def test_misc_types(self, metadata, connection, type_):
-        t = Table("t1", metadata, Column("x", type_))
+    def test_rowid_type(self, metadata, connection):
+        self._run_test(metadata, connection, [(ROWID(), ROWID())], [])
 
-        t.create(connection)
-
-        eq_(
-            inspect(connection).get_columns("t1")[0]["type"]._type_affinity,
-            type_._type_affinity,
-        )
+    def test_raw_type(self, metadata, connection):
+        """Test that RAW columns preserve data_length on reflection."""
+        specs = [
+            (RAW(50), RAW(50)),
+            (RAW(128), RAW(128)),
+        ]
+        self._run_test(metadata, connection, specs, ["length"])
 
 
 class IdentityReflectionTest(fixtures.TablesTest):