Commit Graph

31 Commits

Author SHA1 Message Date
Daniele Varrazzo
8bd7ad7bb5 Faster check for empty range in str() 2018-10-04 11:46:07 +01:00
Michel Albert
d317977205 Implement __str__ for range types 2018-09-30 10:15:55 +02:00
Jon Dufresne
8ad2098b74 Drop 2to3 build step; make all code compatible with all Pythons
Make all library code compatible with both Python 2 and Python 3. Helps
move to modern Python idioms. Can now write for Python 3 (with
workarounds for Python 2) instead of the other way around.

In the future, when it is eventually time to drop Python 2, the library
will be in a better position to remove workarounds

Added a very small comparability module compat.py where required. It
includes definitions for:

- text_type -- A type. str on Python 3. unicode on Python 2.
- string_types -- A tuple. Contains only str on Python 3. Contains str &
                  unicode on Python 2.
2017-12-11 20:26:58 -08:00
Daniele Varrazzo
f939f39580 Use dict comprehensions 2017-11-28 16:11:06 +00:00
Daniele Varrazzo
91d2158de7 Python source cleanup using flake8 2016-10-11 00:11:55 +01:00
Daniele Varrazzo
78649f8e90 Dropped use of b() "macro" and 2to3 fixer
Just use the b"" strings syntax supported from python 2.6.
2016-08-15 01:56:36 +01:00
Jonathan Ross Rogers
cde19c4d59 Make Range pickleable 2016-08-07 02:38:52 +01:00
Daniele Varrazzo
283dbccf56 Merge branch 'range_sort' 2014-02-22 23:02:19 +00:00
Daniele Varrazzo
dd9e476353 Fixed error message on range parsing failed 2014-02-22 23:02:07 +00:00
Daniele Varrazzo
8937c635df Hardcode the list of attributes to be used in comparison
Comparing Range subclasses may lead to surprises.
2014-02-22 21:52:44 +00:00
Daniele Varrazzo
4545d1636c Added implementation for Range gt and ge operators
Using a common implementation for all the operators. Note that lt is the
one used by sort so it's nice it's the fastest.
2014-02-22 21:51:28 +00:00
Chris Withers
e60266c4c5 New implementation of Range sorting that works for Python 2.5 to 3.3, at least. 2014-02-18 20:55:00 +00:00
Chris Withers
d469c32503 Provide a stable and consistent sort order for Range objects.
This matches postgres server-side behaviour and helps client applications that need to sort based on the primary key of tables where the primary key is or contains a range.
2014-02-12 08:11:59 +00:00
Chris Withers
28276e3eb1 cater for comparison of subclasses 2013-05-26 22:20:07 +01:00
Chris Withers
b6a9e0ffaf raising an exception here rather than returning False causes problems with SQLAlchemy's internal state tracking 2013-05-26 21:58:39 +01:00
Chris Withers
8bb44f3444 more useful error message when comparing ranges with non-ranges 2013-05-26 21:20:40 +01:00
Daniele Varrazzo
fc2ca0d2e9 Make sure to return a bytes string from numeric range adapter 2013-04-21 20:30:50 +01:00
Daniele Varrazzo
884a7f7db6 A couple of typos fixed 2013-04-07 16:05:36 +01:00
Daniele Varrazzo
06bfa801f4 Fixed range adaptation on Python 3 2013-03-16 22:12:41 +00:00
Daniele Varrazzo
b8b669611e More helpful error messasge on Range order attempts 2012-09-25 00:07:08 +01:00
Daniele Varrazzo
c756d580f2 Added documentation for range types and adaptation 2012-09-24 00:49:44 +01:00
Daniele Varrazzo
b1953640d2 Don't need to implement __new__ to make an immutable class 2012-09-24 00:49:02 +01:00
Daniele Varrazzo
a858987844 Fixed search of types into schemas.
We don't need to look for stuff implicitly into pg_catalog as all
the builtin ranges are already registered. So just search into
'public' if the schema is not specified.
2012-09-24 00:49:02 +01:00
Daniele Varrazzo
841ddaba87 Range objects cannot be ordered 2012-09-23 22:54:50 +01:00
Daniele Varrazzo
25ef540aa3 Range objects are nonzero when not empty 2012-09-23 22:43:23 +01:00
Daniele Varrazzo
a96a4349ed Range objects are immutable and hashable 2012-09-23 22:40:13 +01:00
Daniele Varrazzo
e002ea5937 Dropped Range._empty attribute
We can do with just _bounds: it will make eq and hash easier to
implement in a consistent way
2012-09-23 22:10:33 +01:00
Daniele Varrazzo
d2cee6f9ad Added in operator for ranges 2012-09-23 22:01:39 +01:00
Daniele Varrazzo
94c6353d55 NumberRange renamed to NumericRange
I was avoiding Numeric to avoid conflicting with the 'numeric'
Postgres type, which is an alias for 'decimal'. But now that there
is a single numeric range I can use the preferred name
2012-09-23 21:11:06 +01:00
Daniele Varrazzo
45cbcc0713 Dropped Range classes for specific numeric types 2012-09-23 21:08:18 +01:00
Daniele Varrazzo
5e7c1d0b51 Added first implementation of Range type, adapter, typecaster 2012-09-23 21:03:36 +01:00