zacharyvoase / django-postgres

First-class Postgres feature support for the Django ORM.
http://django-postgres.readthedocs.org/
The Unlicense
183 stars 28 forks source link

Pony: BitField support #1

Open alex opened 12 years ago

alex commented 12 years ago

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

zacharyvoase commented 12 years ago

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.

alex commented 12 years ago

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

zacharyvoase commented 12 years ago

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

zacharyvoase commented 12 years ago

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.