diff options
Diffstat (limited to 'test/dialect/postgresql')
| -rw-r--r-- | test/dialect/postgresql/test_compiler.py | 12 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_types.py | 13 |
2 files changed, 21 insertions, 4 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index b98d0fac6..98b974ea5 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -243,6 +243,18 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "CAST(bar AS someschema.somename) AS bar", ) + def test_cast_double_pg_double(self): + """test #5465: + + test sqlalchemy Double/DOUBLE to PostgreSQL DOUBLE PRECISION + """ + d1 = sqltypes.Double + + stmt = select(cast(column("foo"), d1)) + self.assert_compile( + stmt, "SELECT CAST(foo AS DOUBLE PRECISION) AS foo" + ) + def test_cast_enum_schema_translate(self): """test #6739""" e1 = Enum("x", "y", "z", name="somename") diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 0c00c7633..a59dd0ac7 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -12,6 +12,7 @@ from sqlalchemy import cast from sqlalchemy import Column from sqlalchemy import column from sqlalchemy import DateTime +from sqlalchemy import Double from sqlalchemy import Enum from sqlalchemy import exc from sqlalchemy import Float @@ -127,14 +128,16 @@ class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): Column("x", postgresql.ARRAY(Float)), Column("y", postgresql.ARRAY(REAL)), Column("z", postgresql.ARRAY(postgresql.DOUBLE_PRECISION)), + Column("w", postgresql.ARRAY(Double)), Column("q", postgresql.ARRAY(Numeric)), ) metadata.create_all(connection) connection.execute( - t1.insert(), dict(x=[5], y=[5], z=[6], q=[decimal.Decimal("6.4")]) + t1.insert(), + dict(x=[5], y=[5], z=[6], w=[7], q=[decimal.Decimal("6.4")]), ) row = connection.execute(t1.select()).first() - eq_(row, ([5], [5], [6], [decimal.Decimal("6.4")])) + eq_(row, ([5], [5], [6], [7], [decimal.Decimal("6.4")])) def test_arrays_base(self, connection, metadata): t1 = Table( @@ -143,14 +146,16 @@ class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): Column("x", sqltypes.ARRAY(Float)), Column("y", sqltypes.ARRAY(REAL)), Column("z", sqltypes.ARRAY(postgresql.DOUBLE_PRECISION)), + Column("w", sqltypes.ARRAY(Double)), Column("q", sqltypes.ARRAY(Numeric)), ) metadata.create_all(connection) connection.execute( - t1.insert(), dict(x=[5], y=[5], z=[6], q=[decimal.Decimal("6.4")]) + t1.insert(), + dict(x=[5], y=[5], z=[6], w=[7], q=[decimal.Decimal("6.4")]), ) row = connection.execute(t1.select()).first() - eq_(row, ([5], [5], [6], [decimal.Decimal("6.4")])) + eq_(row, ([5], [5], [6], [7], [decimal.Decimal("6.4")])) class EnumTest(fixtures.TestBase, AssertsExecutionResults): |
