diff --git a/Changelog b/Changelog index 81c93c9..c9da93b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +2024-01-31 + * Drop support for SQLALchemy 1.1, 1.2 and 1.3 + * Add support for SQLALchemy >=2.0 + * Add support for Flask-SQLAlchemy >=3.1 + 2022-03-23 * Django: Support for UUIDField @@ -174,7 +179,7 @@ # No errors will be raised user = mixer.blend('auth.User', username='mike') null = mixer.blend('auth.User', username='mike') - + 2014-01-03 horneds diff --git a/mixer/__init__.py b/mixer/__init__.py index 263218f..6e611a5 100644 --- a/mixer/__init__.py +++ b/mixer/__init__.py @@ -14,7 +14,7 @@ # Module information # ================== -__version__ = "7.2.2" +__version__ = "7.3.0" __project__ = "mixer" __author__ = "horneds " __license__ = "BSD" diff --git a/mixer/backend/flask.py b/mixer/backend/flask.py index d22a79e..1f9cc85 100644 --- a/mixer/backend/flask.py +++ b/mixer/backend/flask.py @@ -44,7 +44,11 @@ def init_app(self, app): """ assert app.extensions and app.extensions[ 'sqlalchemy'], "Flask-SQLAlchemy must be inialized before Mixer." - db = app.extensions['sqlalchemy'].db + try: + db = app.extensions['sqlalchemy'].db + except AttributeError: + # https://github.com/pallets-eco/flask-sqlalchemy/issues/698#issuecomment-1250351168 + db = app.extensions['sqlalchemy'] self.params['session'] = db.session # register extension with app diff --git a/requirements-tests.txt b/requirements-tests.txt index 2cc7528..6a2a575 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,7 +1,7 @@ Django >= 3.0 Flask >= 1.0 Marshmallow >= 3.9 -SQLAlchemy >= 1.1.4 +SQLAlchemy >= 1.4 flask-sqlalchemy >= 2.1 mongoengine >= 0.10.1 peewee >= 3.7.0 diff --git a/tests/test_sqlalchemy.py b/tests/test_sqlalchemy.py index 764518e..cd86ac3 100644 --- a/tests/test_sqlalchemy.py +++ b/tests/test_sqlalchemy.py @@ -18,8 +18,7 @@ ) from sqlalchemy.dialects import mssql, mysql, oracle, postgresql, sqlite from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relation, relationship, scoped_session, sessionmaker -from sqlalchemy.util import text_type +from sqlalchemy.orm import relationship, scoped_session, sessionmaker ENGINE = create_engine('sqlite:///:memory:') BASE = declarative_base() @@ -71,7 +70,7 @@ class Role(BASE): name = Column(String(20), primary_key=True) user_id = Column(Integer, ForeignKey(User.id), nullable=False) - user = relation(User) + user = relationship(User) BASE.metadata.create_all(ENGINE) @@ -245,4 +244,4 @@ class Test(base): def test_random_compiled(dialect, expected): from mixer.backend.sqlalchemy import random compiled = random().compile(dialect=dialect) - assert text_type(compiled) == expected + assert str(compiled) == expected