django-postgres icon indicating copy to clipboard operation
django-postgres copied to clipboard

Pony: BitField support

Open alex opened this issue 11 years ago • 4 comments

PostgreSQL has awesome support for bit fields, this should support 'em!

alex avatar Aug 20 '12 23:08 alex

Happening.

Also happening:

>>> Model.objects.filter(bitfield__xor='110101')
>>> Model.objects.update(bitfield=B('bitfield') ^ '110101')

Et cetera. I like ExpressionNode for this kind of stuff.

zacharyvoase avatar Aug 21 '12 00:08 zacharyvoase

Awesome, didn't see it noted in the "future" section, so I figured I'd bring it up.

alex avatar Aug 21 '12 00:08 alex

Yup. Seems easy enough to implement; I may be able to get it done this arvo.

zacharyvoase avatar Aug 21 '12 00:08 zacharyvoase

OK. Not that easy to implement.

There's a basic implementation of the BIT and VARBIT types here. There’s also a B()-expression syntax thing for manipulating bit strings atomically; see these test cases for a short example.

The biggest problem, currently, is the implementation of custom query predicates based on the bitwise operators. Stuff like __xor, which I think would be really useful. Also, I’d love a query aggregate like popcount(), but apparently Postgres doesn’t even have that built-in.

zacharyvoase avatar Aug 21 '12 08:08 zacharyvoase