diff --git a/CHANGES.rst b/CHANGES.rst index 7f69116..9d00d36 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,13 @@ Changelog Here you can see the full list of changes between each SQLAlchemy-Utils release. +0.8.1 (2013-04-02) +^^^^^^^^^^^^^^^^^^ + +- Removed unnecessary print statement form ScalarList +- Documentation for ScalarList and NumberRange + + 0.8.0 (2013-04-02) ^^^^^^^^^^^^^^^^^^ diff --git a/docs/index.rst b/docs/index.rst index 3ad44ba..de317bf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -51,6 +51,49 @@ You can easily set up integer lists too: session.commit() +NumberRange +----------- + +NumberRangeType provides way for saving range of numbers into database. + +Example :: + + + from sqlalchemy_utils import NumberRangeType, NumberRange + + + class Event(Base): + __tablename__ = 'user' + id = db.Column(db.Integer, autoincrement=True) + name = db.Column(db.Unicode(255)) + estimated_number_of_persons = db.Column(NumberRangeType) + + + party = Event(name=u'party') + + # we estimate the party to contain minium of 10 persons and at max + # 100 persons + party.estimated_number_of_persons = NumberRange(10, 100) + + print party.estimated_number_of_persons + # '10-100' + + +NumberRange supports some arithmetic operators: +:: + + + meeting = Event(name=u'meeting') + + meeting.estimated_number_of_persons = NumberRange(20, 40) + + total = ( + meeting.estimated_number_of_persons + + party.estimated_number_of_persons + ) + print total + # '30-140' + API Documentation ----------------- diff --git a/setup.py b/setup.py index c441cca..e4102af 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ class PyTest(Command): setup( name='SQLAlchemy-Utils', - version='0.8.0', + version='0.8.1', url='https://github.com/kvesteri/sqlalchemy-utils', license='BSD', author='Konsta Vesterinen', diff --git a/sqlalchemy_utils/types.py b/sqlalchemy_utils/types.py index d504c0d..d4197c3 100644 --- a/sqlalchemy_utils/types.py +++ b/sqlalchemy_utils/types.py @@ -98,7 +98,6 @@ class ScalarList(types.TypeDecorator): # Convert list of values to unicode separator-separated list # Example: [1, 2, 3, 4] -> u'1, 2, 3, 4' if value: - print value if any(self.separator in unicode(item) for item in value): raise ScalarListException( "List values can't contain string '%s' (its being used as "