summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/requirements.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-12-20 10:20:10 -0700
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-20 23:18:04 -0500
commit3b8a14153da9e7b6694571fa10f6d30c4012ee82 (patch)
tree89c26616a9088bad7c9c0c195fa96fcc24b5fe13 /lib/sqlalchemy/testing/requirements.py
parenta8f51f3c11f3cb2e344732cf3abb371f03ed30d8 (diff)
downloadsqlalchemy-3b8a14153da9e7b6694571fa10f6d30c4012ee82.tar.gz
Fix issues with JSON and float/numeric
Decimal accuracy and behavior has been improved when extracting floating point and/or decimal values from JSON strings using the :meth:`_sql.sqltypes.JSON.Comparator.as_float` method, when the numeric value inside of the JSON string has many significant digits; previously, MySQL backends would truncate values with many significant digits and SQL Server backends would raise an exception due to a DECIMAL cast with insufficient significant digits. Both backends now use a FLOAT-compatible approach that does not hardcode significant digits for floating point values. For precision numerics, a new method :meth:`_sql.sqltypes.JSON.Comparator.as_numeric` has been added which accepts arguments for precision and scale, and will return values as Python ``Decimal`` objects with no floating point conversion assuming the DBAPI supports it (all but pysqlite). Fixes: #5788 Change-Id: I6eb51fe172a389548dd6e3c65efec9f1f538012e
Diffstat (limited to 'lib/sqlalchemy/testing/requirements.py')
-rw-r--r--lib/sqlalchemy/testing/requirements.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py
index 7ff3fcf38..30b42cbf3 100644
--- a/lib/sqlalchemy/testing/requirements.py
+++ b/lib/sqlalchemy/testing/requirements.py
@@ -871,6 +871,14 @@ class SuiteRequirements(Requirements):
return exclusions.closed()
@property
+ def cast_precision_numerics_many_significant_digits(self):
+ """same as precision_numerics_many_significant_digits but within the
+ context of a CAST statement (hello MySQL)
+
+ """
+ return self.precision_numerics_many_significant_digits
+
+ @property
def implicit_decimal_binds(self):
"""target backend will return a selected Decimal as a Decimal, not
a string.