diff --git a/dataset/types.py b/dataset/types.py index 904ffa9..d30d3c1 100644 --- a/dataset/types.py +++ b/dataset/types.py @@ -2,6 +2,7 @@ from datetime import datetime, date from sqlalchemy import Integer, UnicodeText, Float, BigInteger from sqlalchemy import Boolean, Date, DateTime, Unicode, JSON +from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.types import TypeEngine @@ -16,25 +17,21 @@ class Types(object): date = Date datetime = DateTime - def __init__(self, dialect = None): + def __init__(self, dialect=None): self._dialect = dialect @property def json(self): if self._dialect is not None and self._dialect == 'postgresql': - from sqlalchemy.dialects.postgresql import JSONB return JSONB return JSON - def guess(self, sample, dialect = None): + def guess(self, sample): """Given a single sample, guess the column type for the field. If the sample is an instance of an SQLAlchemy type, the type will be used instead. """ - if dialect is not None: - self._dialect = dialect - if isinstance(sample, TypeEngine): return sample if isinstance(sample, bool):