Re: Range Type Support
От | Federico Di Gregorio |
---|---|
Тема | Re: Range Type Support |
Дата | |
Msg-id | 505ACA34.8040803@dndg.it обсуждение исходный текст |
Ответ на | Re: Range Type Support (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Список | psycopg |
On 20/09/2012 02:18, Daniele Varrazzo wrote: >>> - Possibly it should support an "in" operator and an & operator. But >>> >> then, should we mimic all the operators? >>> >> <http://www.postgresql.org/docs/9.2/static/functions-range.html> >>> >> Probably not. >> > >> > By "&" do you mean "&&"? Part of me thinks we should support overlaps, but part of the power of the range types featureis that Postgres can handle overlap operations (which are nontrivial to build). I see "in" being used a lot. > There's no && operator in python. But you are sorta right: I was > thinking about an operator saying if two intervals match, not to > return their intersection. But would it be any useful? It's definitely > little thing compared to the richness of the postgres range type and > implementing all of them is a project on its own. "in" otoh would be > easy to implement. > After we have a basic range type we can add operators as methods (IMO, in this case operator "overloading" in Python is not what we want). So you can have: range1.overlaps(range2) range1.inside(range2) and so on. "in" can be an alias for one of such methods. In fact a range type is so useful that I am amazed it doesn't already exists in Python. federico -- Federico Di Gregorio federico.digregorio@dndg.it Studio Associato Di Nunzio e Di Gregorio http://dndg.it Qu'est ce que la folie? Juste un sentiment de liberté si fort qu'on en oublie ce qui nous rattache au monde... -- J. de Loctra
В списке psycopg по дате отправления: