summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-08-03 14:08:32 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-08-03 20:47:27 -0400
commitf684bb7659ff195d4c55414162c1de4fbfdafc2f (patch)
treef5bb7d7a4d2e03af9470ed2c539acd33ae6462d9 /test/dialect/postgresql/test_compiler.py
parentea6fb4ff5bcffcf71cdbc587504f10f03fe921ca (diff)
downloadsqlalchemy-f684bb7659ff195d4c55414162c1de4fbfdafc2f.tar.gz
ensure RETURNING renders in stringify w/ no server version
just in my own testing, if I say insert().return_defaults() and stringify, I should see it, so make sure all the dialects default to "insert_returning" etc. , with downgrade on server version check. Change-Id: Id64e78fcb03c48b5dcb0feb21cb9cc495edd15e9
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 9be76130d..5e5c4f9bd 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -56,6 +56,7 @@ from sqlalchemy.testing import fixtures
from sqlalchemy.testing.assertions import assert_raises
from sqlalchemy.testing.assertions import assert_raises_message
from sqlalchemy.testing.assertions import AssertsCompiledSQL
+from sqlalchemy.testing.assertions import eq_ignore_whitespace
from sqlalchemy.testing.assertions import expect_warnings
from sqlalchemy.testing.assertions import is_
from sqlalchemy.util import OrderedDict
@@ -101,6 +102,21 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = postgresql.dialect()
+ def test_plain_stringify_returning(self):
+ t = Table(
+ "t",
+ MetaData(),
+ Column("myid", Integer, primary_key=True),
+ Column("name", String, server_default="some str"),
+ Column("description", String, default=func.lower("hi")),
+ )
+ stmt = t.insert().values().return_defaults()
+ eq_ignore_whitespace(
+ str(stmt.compile(dialect=postgresql.dialect())),
+ "INSERT INTO t (description) VALUES (lower(%(lower_1)s)) "
+ "RETURNING t.myid, t.name, t.description",
+ )
+
def test_update_returning(self):
dialect = postgresql.dialect()
table1 = table(