Skip to content

Commit

Permalink
Peewee 3.x compatibility
Browse files Browse the repository at this point in the history
`PrimaryKeyField` has been renamed to `AutoField`.
The `isinstance` check in `gen_field` therefore fails
and no objects are created.
  • Loading branch information
jberkel committed Sep 26, 2018
1 parent 1607225 commit a24f9c2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mixer/backend/peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from __future__ import absolute_import

from peewee import * # noqa
try:
from peewee import AutoField
except ImportError:
from peewee import PrimaryKeyField as AutoField

import datetime
import decimal

Expand Down Expand Up @@ -39,7 +44,7 @@ class GenFactory(BaseFactory):
""" Map a peewee classes to simple types. """

types = {
PrimaryKeyField: t.PositiveInteger,
AutoField: t.PositiveInteger,
IntegerField: int,
BigIntegerField: t.BigInteger,
(FloatField, DoubleField): float,
Expand Down Expand Up @@ -75,7 +80,7 @@ def populate_target(self, values):

def gen_field(self, field):
""" Function description. """
if isinstance(field.scheme, PrimaryKeyField)\
if isinstance(field.scheme, AutoField)\
and self.__mixer and self.__mixer.params.get('commit'):
return field.name, SKIP_VALUE
return super(TypeMixer, self).gen_field(field)
Expand Down

0 comments on commit a24f9c2

Please sign in to comment.