Skip to content

Commit

Permalink
handle None parameters in query, returning NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
fobispotc committed Sep 8, 2024
1 parent 0a322a2 commit 3eb681d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion asyncpg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ async def _mogrify(conn, query, args):

# Finally, replace $n references with text values.
return re.sub(
r'\$(\d+)\b', lambda m: textified[int(m.group(1)) - 1], query)
r"\$(\d+)\b",
lambda m: (
textified[int(m.group(1)) - 1]
if textified[int(m.group(1)) - 1] is not None
else "NULL"
),
query,
)

0 comments on commit 3eb681d

Please sign in to comment.