You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the look at the code, asyncpg.BitString simply doesn't implement bitwise operators nor op() methods?
But our business logic includes comparing and performing bitwise operations on long (>400 bits) bit strings.
It works in raw SQL, but apparently doesn't work with sqlalchemy/asyncpg? What should we do?
UPD I eventually settled with this:
from sqlalchemy.dialects.postgresql import BIT
from asyncpg import BitString
cast(BitString(bitmask), BIT(varying=True))
where bitmask is user input string of 0 and 1, so it can do bitwise_xor(), bitwise_not() etc., but this is less than ideal.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
From the look at the code, asyncpg.BitString simply doesn't implement bitwise operators nor op() methods?
But our business logic includes comparing and performing bitwise operations on long (>400 bits) bit strings.
It works in raw SQL, but apparently doesn't work with sqlalchemy/asyncpg? What should we do?
UPD I eventually settled with this:
where bitmask is user input string of 0 and 1, so it can do bitwise_xor(), bitwise_not() etc., but this is less than ideal.
Beta Was this translation helpful? Give feedback.
All reactions