]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add tests for Oracle tablespace specification in table definitions
authorMiguel Grillo <miguel_grillo_orellana@hotmail.com>
Mon, 21 Oct 2024 23:02:56 +0000 (01:02 +0200)
committerMiguel Grillo <miguel_grillo_orellana@hotmail.com>
Mon, 21 Oct 2024 23:02:56 +0000 (01:02 +0200)
This commit adds new tests to verify the correct handling of tablespace names in Oracle table definitions. The tests ensure that tablespace names are recognized correctly regardless of their case (uppercase, lowercase, mixed case).

Tests added:
- : Verifies that tablespace names are correctly included in the CREATE TABLE statement for different cases:
  - Uppercase tablespace name
  - Lowercase tablespace name
  - Mixed case tablespace name

These tests ensure that the  argument is handled correctly and that the generated SQL statements include the specified tablespace names as expected.

test/dialect/oracle/test_compiler.py

index 972a02dad8d2cf89653fec519e6796f4eed570a5..795fbccdfbdac7431757779e8c331be419d70e46 100644 (file)
@@ -1659,6 +1659,46 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             cast(column("foo"), d1), "CAST(foo AS DOUBLE PRECISION)"
         )
 
+    def test_table_tablespace(self):
+        m = MetaData()
+
+        t = Table(
+            "table1",
+            m,
+            Column("x", Integer),
+            oracle_tablespace='TEST_TABLESPACE',
+        )
+        t2 = Table(
+            "table2",
+            m,
+            Column("x", Integer),
+            oracle_tablespace='test_tablespace',
+        )
+        t3 = Table(
+            "table3",
+            m,
+            Column("x", Integer),
+            oracle_tablespace='TestTableSpace',
+        )
+        self.assert_compile(
+            schema.CreateTable(t),
+            "CREATE TABLE "
+            "table1 (x INTEGER) "
+            'TABLESPACE "TEST_TABLESPACE"',
+        )
+        self.assert_compile(
+            schema.CreateTable(t2),
+            "CREATE TABLE "
+            "table2 (x INTEGER) "
+            'TABLESPACE test_tablespace',
+        )
+        self.assert_compile(
+            schema.CreateTable(t3),
+            "CREATE TABLE "
+            "table3 (x INTEGER) "
+            'TABLESPACE "TestTableSpace"',
+        )
+
 
 class SequenceTest(fixtures.TestBase, AssertsCompiledSQL):
     def test_basic(self):