Skip to content

Commit c78eec1

Browse files
fobispotcelprans
authored andcommitted
handle None parameters in query, returning NULL
1 parent aa2d0e6 commit c78eec1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

asyncpg/utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ async def _mogrify(conn, query, args):
4242

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

0 commit comments

Comments
 (0)