From 6a0d61f12110624ad8709f67d4523e82bde262e5 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 26 Apr 2023 10:34:46 -0400 Subject: ensure correct cast for floats vs. numeric; other fixes Fixed regression caused by the fix for :ticket:`9618` where floating point values would lose precision being inserted in bulk, using either the psycopg2 or psycopg drivers. Implemented the :class:`_sqltypes.Double` type for SQL Server, having it resolve to ``REAL``, or :class:`_mssql.REAL`, at DDL rendering time. Fixed issue in Oracle dialects where ``Decimal`` returning types such as :class:`_sqltypes.Numeric` would return floating point values, rather than ``Decimal`` objects, when these columns were used in the :meth:`_dml.Insert.returning` clause to return INSERTed values. Fixes: #9701 Change-Id: I8865496a6ccac6d44c19d0ca2a642b63c6172da9 --- lib/sqlalchemy/dialects/postgresql/_psycopg_common.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/_psycopg_common.py') diff --git a/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py b/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py index 739cbc5a9..b98518099 100644 --- a/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py +++ b/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py @@ -55,6 +55,10 @@ class _PsycopgNumeric(sqltypes.Numeric): ) +class _PsycopgFloat(_PsycopgNumeric): + __visit_name__ = "float" + + class _PsycopgHStore(HSTORE): def bind_processor(self, dialect): if dialect._has_native_hstore: @@ -104,6 +108,7 @@ class _PGDialect_common_psycopg(PGDialect): PGDialect.colspecs, { sqltypes.Numeric: _PsycopgNumeric, + sqltypes.Float: _PsycopgFloat, HSTORE: _PsycopgHStore, sqltypes.ARRAY: _PsycopgARRAY, INT2VECTOR: _PsycopgINT2VECTOR, -- cgit v1.2.1