Skip to content

Commit d9bee25

Browse files
committed
Fix boolean transformer for falsey values.
It's best to be explicit when checking for None, otherwise 0 and False will count as None.
1 parent d90635a commit d9bee25

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

pgsqlite/pgsqlite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ async def sem_task(coro):
146146
return await asyncio.gather(*(sem_task(coro) for coro in coros))
147147

148148
def boolean_transformer(self, val: Any, nullable: bool) -> Union[bool, None]:
149-
if nullable and not val:
149+
if nullable and val is None:
150150
return None
151-
if not nullable and not val:
151+
if not nullable and val is None:
152152
raise Exception("Value is None but column is not nullable")
153153

154-
if val == 1 or val.lower() == "true":
154+
if val == 1 or str(val).lower() == "true":
155155
return "TRUE"
156156
return "FALSE"
157157

0 commit comments

Comments
 (0)