From 563180f7d46b24bd334d227104c90bf8cdb81158 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 26 Jun 2017 16:50:24 -0400 Subject: Coerce to float for Float with all native decimal backends The result processor for the :class:`.Float` type now unconditionally runs values through the ``float()`` processor if the dialect specifies that it also supports "native decimal" mode. While most backends will deliver Python ``float`` objects for a floating point datatype, the MySQL backends in some cases lack the typing information in order to provide this and return ``Decimal`` unless the float conversion is done. Change-Id: I638f1480fb00a507036efaf0e0080f26893d98ad Fixes: #4020 --- lib/sqlalchemy/sql/sqltypes.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 5b53f390e..6838baa5f 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -702,6 +702,8 @@ class Float(Numeric): return processors.to_decimal_processor_factory( decimal.Decimal, self._effective_decimal_return_scale) + elif dialect.supports_native_decimal: + return processors.to_float else: return None -- cgit v1.2.1