diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-06-15 12:42:44 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-06-15 14:32:53 -0400 |
| commit | 46c0fa56e904f6a00e56343302c4cb39955fa038 (patch) | |
| tree | 7417ab317303299916ed7f2a6843bc5ce5e1634a /test/dialect | |
| parent | 6d889b03dcd42b531001aeec2737949dca41d6d8 (diff) | |
| download | sqlalchemy-46c0fa56e904f6a00e56343302c4cb39955fa038.tar.gz | |
implement literal stringification for arrays
as we already implement stringification for the contents,
provide a bracketed syntax for default and ARRAY literal
for PG specifically. ARRAY literal seems much simpler to
render than their quoted syntax which requires double quotes
for strings.
also open up testing for pg8000 which has likely been
fine with arrays for awhile now, bump the version pin
also.
Fixes: #8138
Change-Id: Id85b052b0a9564d6aa1489160e58b7359f130fdd
Diffstat (limited to 'test/dialect')
| -rw-r--r-- | test/dialect/postgresql/test_types.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 266263d5f..fd4b91db1 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -19,6 +19,7 @@ from sqlalchemy import Float from sqlalchemy import func from sqlalchemy import inspect from sqlalchemy import Integer +from sqlalchemy import literal from sqlalchemy import MetaData from sqlalchemy import null from sqlalchemy import Numeric @@ -52,6 +53,7 @@ from sqlalchemy.orm import Session from sqlalchemy.sql import bindparam from sqlalchemy.sql import operators from sqlalchemy.sql import sqltypes +from sqlalchemy.testing import expect_raises_message from sqlalchemy.testing import fixtures from sqlalchemy.testing.assertions import assert_raises from sqlalchemy.testing.assertions import assert_raises_message @@ -64,6 +66,7 @@ from sqlalchemy.testing.assertsql import RegexSQL from sqlalchemy.testing.schema import pep435_enum from sqlalchemy.testing.suite import test_types as suite from sqlalchemy.testing.util import round_decimal +from sqlalchemy.types import UserDefinedType class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): @@ -1230,6 +1233,23 @@ class ArrayTest(AssertsCompiledSQL, fixtures.TestBase): render_postcompile=True, ) + def test_array_literal_render_no_inner_render(self): + class MyType(UserDefinedType): + cache_ok = True + + def get_col_spec(self, **kw): + return "MYTYPE" + + with expect_raises_message( + NotImplementedError, + r"Don't know how to literal-quote value \[1, 2, 3\]", + ): + self.assert_compile( + select(literal([1, 2, 3], ARRAY(MyType()))), + "nothing", + literal_binds=True, + ) + def test_array_in_str_psycopg2_cast(self): expr = column("x", postgresql.ARRAY(String(15))).in_( [["one", "two"], ["three", "four"]] |
