]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Correct #7664 to include DropSchema
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jan 2023 14:37:50 +0000 (09:37 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jan 2023 14:39:24 +0000 (09:39 -0500)
Corrected the fix for :ticket:`7664`, released in version 2.0.0, to also
include :class:`.DropSchema` which was inadvertently missed in this fix,
allowing stringification without a dialect. The fixes for both constructs
is backported to the 1.4 series as of 1.4.47.

Fixes: #7664
Change-Id: I509b7500ee496ac1e444ea2096c2a02520167e6d

doc/build/changelog/changelog_20.rst
doc/build/changelog/unreleased_14/7664.rst
doc/build/changelog/unreleased_20/7664_update.rst [new file with mode: 0644]
lib/sqlalchemy/sql/ddl.py
test/sql/test_metadata.py

index 8f604dbca6f8d6e411821dce4db9b980ab19f47a..a91a137981990c5da3d058272b88cd0a2cc43090 100644 (file)
     :version: 2.0.0
     :released: January 26, 2023
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 7664
+
+        Fixed stringify for a the :class:`.CreateSchema` DDL construct, which
+        would fail with an ``AttributeError`` when stringified without a
+        dialect. Update: Note this fix failed to accommodate for
+        :class:`.DropSchema`; a followup fix in version 2.0.1 repairs this
+        case. The fix for both elements is backported to 1.4.47.
+
     .. change::
         :tags: usecase, orm extensions
         :tickets: 5145
index 5e4ae56890ae748e48485314e5e37da15d429b9e..466eae8bc95ac2c50711de1e34a92813631ffcc3 100644 (file)
@@ -1,8 +1,8 @@
 .. change::
     :tags: bug, sql
     :tickets: 7664
-    :versions: 2.0.0
 
-    Fixed stringify for a the :class:`.CreateSchema` DDL construct, which would
-    fail with an ``AttributeError`` when stringified without a dialect.
+    Fixed stringify for a the :class:`.CreateSchema` and :class:`.DropSchema`
+    DDL constructs, which would fail with an ``AttributeError`` when
+    stringified without a dialect.
 
diff --git a/doc/build/changelog/unreleased_20/7664_update.rst b/doc/build/changelog/unreleased_20/7664_update.rst
new file mode 100644 (file)
index 0000000..8f6199e
--- /dev/null
@@ -0,0 +1,9 @@
+.. change::
+    :tags: bug, sql
+    :tickets: 7664
+
+    Corrected the fix for :ticket:`7664`, released in version 2.0.0, to also
+    include :class:`.DropSchema` which was inadvertently missed in this fix,
+    allowing stringification without a dialect. The fixes for both constructs
+    is backported to the 1.4 series as of 1.4.47.
+
index 715e364272578d40a36c8fd894fb42aecc979ad7..826ff687e134e209f28e5cd467474d99da512cea 100644 (file)
@@ -497,6 +497,8 @@ class DropSchema(_DropBase):
 
     __visit_name__ = "drop_schema"
 
+    stringify_dialect = "default"  # type: ignore
+
     def __init__(
         self,
         name,
index 0cd73922e9f7d6c10670f56369f4234e0d5410af..684ad3a075d55833bc8604231881e7dee4a9c237 100644 (file)
@@ -2623,6 +2623,7 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
 
     @testing.combinations(
         (schema.CreateSchema("sa_schema"), "CREATE SCHEMA sa_schema"),
+        (schema.DropSchema("sa_schema"), "DROP SCHEMA sa_schema"),
         # note we don't yet support lower-case table() or
         # lower-case column() for this
         # (
@@ -2633,6 +2634,10 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
             schema.CreateTable(Table("t", MetaData(), Column("q", Integer))),
             "CREATE TABLE t (q INTEGER)",
         ),
+        (
+            schema.DropTable(Table("t", MetaData(), Column("q", Integer))),
+            "DROP TABLE t",
+        ),
         (
             schema.CreateIndex(
                 Index(
@@ -2643,6 +2648,18 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
             ),
             "CREATE INDEX foo ON t (x)",
         ),
+        (
+            schema.DropIndex(
+                Index(
+                    "foo",
+                    "x",
+                    _table=Table("t", MetaData(), Column("x", Integer)),
+                )
+            ),
+            "DROP INDEX foo",
+        ),
+        (schema.CreateSequence(Sequence("my_seq")), "CREATE SEQUENCE my_seq"),
+        (schema.DropSequence(Sequence("my_seq")), "DROP SEQUENCE my_seq"),
     )
     def test_stringify_schema_elements(self, element, expected):
         eq_ignore_whitespace(str(element), expected)