--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 7283
+
+ Changed the asyncpg dialect to bind the :class:`.Float` type to the "float"
+ PostgreSQL type instead of "numeric" so that the value ``float(inf)`` can
+ be accommodated. Added test suite support for persisence of the "inf"
+ value.
+
class AsyncpgNumeric(sqltypes.Numeric):
+ def get_dbapi_type(self, dbapi):
+ return dbapi.NUMBER
+
def bind_processor(self, dialect):
return None
)
+class AsyncpgFloat(AsyncpgNumeric):
+ def get_dbapi_type(self, dbapi):
+ return dbapi.FLOAT
+
+
class AsyncpgREGCLASS(REGCLASS):
def get_dbapi_type(self, dbapi):
return dbapi.STRING
sqltypes.Integer: AsyncpgInteger,
sqltypes.BigInteger: AsyncpgBigInteger,
sqltypes.Numeric: AsyncpgNumeric,
+ sqltypes.Float: AsyncpgFloat,
sqltypes.JSON: AsyncpgJSON,
json.JSONB: AsyncpgJSONB,
sqltypes.JSON.JSONPathType: AsyncpgJSONPathType,
return exclusions.closed()
+ @property
+ def infinity_floats(self):
+ """The Float type can persist and load float('inf'), float('-inf')."""
+
+ return exclusions.closed()
+
@property
def precision_generic_float_type(self):
"""target backend will return native floating point numbers with at
[15.7563],
)
+ @testing.requires.infinity_floats
+ def test_infinity_floats(self, do_numeric_test):
+ """test for #977, #7283"""
+
+ do_numeric_test(
+ Float(None),
+ [float("inf")],
+ [float("inf")],
+ )
+
@testing.requires.fetch_null_from_numeric
def test_numeric_null_as_decimal(self, do_numeric_test):
do_numeric_test(Numeric(precision=8, scale=4), [None], [None])
]
)
+ @property
+ def infinity_floats(self):
+ return fails_on_everything_except(
+ "sqlite", "postgresql+psycopg2", "postgresql+asyncpg"
+ ) + skip_if(
+ "postgresql+pg8000", "seems to work on pg14 only, not earlier?"
+ )
+
@property
def precision_generic_float_type(self):
"""target backend will return native floating point numbers with at