Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

asyncpg.BitString bitwise operators #1019

Unanswered
kiranzo asked this question in Q&A
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /