Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1020 Infinity numeric support #1067

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asyncpg/pgproto
35 changes: 25 additions & 10 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,17 +633,32 @@ async def test_numeric(self):
"SELECT $1::numeric", decimal.Decimal('sNaN'))
self.assertTrue(res.is_nan())

with self.assertRaisesRegex(asyncpg.DataError,
'numeric type does not '
'support infinite values'):
await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal('-Inf'))
if self.server_version < (14, 0):
with self.assertRaisesRegex(
asyncpg.DataError,
'invalid sign in external "numeric" value'
):
await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal('-Inf'))

with self.assertRaisesRegex(asyncpg.DataError,
'numeric type does not '
'support infinite values'):
await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal('+Inf'))
with self.assertRaisesRegex(
asyncpg.DataError,
'invalid sign in external "numeric" value'
):
await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal('+Inf'))

with self.assertRaisesRegex(asyncpg.DataError, 'invalid'):
await self.con.fetchval(
"SELECT $1::numeric", 'invalid')
else:
res = await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal("-Inf"))
self.assertTrue(res.is_infinite())

res = await self.con.fetchval(
"SELECT $1::numeric", decimal.Decimal("+Inf"))
self.assertTrue(res.is_infinite())

with self.assertRaisesRegex(asyncpg.DataError, 'invalid'):
await self.con.fetchval(
Expand Down