python-postgres / be

pg-python: Execute Python 3 code from PostgreSQL functions.
Other
5 stars 2 forks source link

Implement type based operator selector #25

Open jwp opened 14 years ago

jwp commented 14 years ago

Currently, there is not an easy way to get PG's binary operators' functions for a specific pair of types.

All Python operators can return arbitrary objects. We can take advantage of this by giving Postgres.Type instances operator methods that return the function associated with the corresponding PG operator:

from Postgres.types import int2, int4, int8

map(int2 < int4, [(123,5432100), ...])