summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-01-24 15:34:27 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-01-24 15:34:27 -0500
commit90f4b5d84f248d95f3df38e74be92b23fd880e42 (patch)
tree4f7a3d8aa3c354be36ed697c8de0d4646e8c985c /test/sql
parent4d2f24e524c99d8255f451476679f5fa93647ad4 (diff)
downloadsqlalchemy-90f4b5d84f248d95f3df38e74be92b23fd880e42.tar.gz
fix stringify for CreateSchema
Fixed stringify for a the :class:`.CreateSchema` DDL construct, which would fail with an ``AttributeError`` when stringified without a dialect. Fixes: #7664 Change-Id: Ifc1769604bc5219c060f5112f7bdea0f780f1a1c
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_metadata.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 7f6bee72b..0cd73922e 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -53,6 +53,7 @@ from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import ComparesTables
from sqlalchemy.testing import emits_warning
from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_ignore_whitespace
from sqlalchemy.testing import expect_raises_message
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
@@ -2620,7 +2621,34 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
t2 = Table("t2", m, Column("x", Integer, ForeignKey("bar.t1.x")))
assert t2.c.x.references(t1.c.x)
+ @testing.combinations(
+ (schema.CreateSchema("sa_schema"), "CREATE SCHEMA sa_schema"),
+ # note we don't yet support lower-case table() or
+ # lower-case column() for this
+ # (
+ # schema.CreateTable(table("t", column("q", Integer))),
+ # "CREATE TABLE t (q INTEGER)",
+ # ),
+ (
+ schema.CreateTable(Table("t", MetaData(), Column("q", Integer))),
+ "CREATE TABLE t (q INTEGER)",
+ ),
+ (
+ schema.CreateIndex(
+ Index(
+ "foo",
+ "x",
+ _table=Table("t", MetaData(), Column("x", Integer)),
+ )
+ ),
+ "CREATE INDEX foo ON t (x)",
+ ),
+ )
+ def test_stringify_schema_elements(self, element, expected):
+ eq_ignore_whitespace(str(element), expected)
+
def test_create_drop_schema(self):
+
self.assert_compile(
schema.CreateSchema("sa_schema"), "CREATE SCHEMA sa_schema"
)