summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorminimumserious <commande.romain@gmail.com>2013-06-13 09:28:42 +0200
committerRaphaƫl Barrois <raphael.barrois@polytechnique.org>2013-06-20 01:40:14 +0200
commit94048a282ed8085df4f6f08931dd1c3804236b76 (patch)
treef524850b334f75ede1d79266c6e9d8530b2f724e /factory
parente3e654a2686d195bcad4ca2723bf31936af2d270 (diff)
downloadfactory-boy-94048a282ed8085df4f6f08931dd1c3804236b76.tar
factory-boy-94048a282ed8085df4f6f08931dd1c3804236b76.tar.gz
Cleaning
Diffstat (limited to 'factory')
-rw-r--r--factory/alchemy.py8
1 files changed, 1 insertions, 7 deletions
diff --git a/factory/alchemy.py b/factory/alchemy.py
index 87a17fa..8ede97f 100644
--- a/factory/alchemy.py
+++ b/factory/alchemy.py
@@ -18,15 +18,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-
from . import base
-try:
- from sqlalchemy.sql.functions import max
-except ImportError:
- def max():
- raise ImportError('sqlalchemy is not found!')
-
class SQLAlchemyModelFactory(base.Factory):
"""Factory for SQLAlchemy models. """
@@ -36,6 +29,7 @@ class SQLAlchemyModelFactory(base.Factory):
@classmethod
def _setup_next_sequence(cls, *args, **kwargs):
"""Compute the next available PK, based on the 'pk' database field."""
+ from sqlalchemy.sql.functions import max
session = cls.FACTORY_SESSION
pk = cls.FACTORY_FOR.__table__.primary_key.columns.values()[0].key
max_pk = session.query(max(getattr(cls.FACTORY_FOR, pk))).one()