From 13c897f00442944a9aa09d46465acb08a62e715e Mon Sep 17 00:00:00 2001 From: Ricardo Madriz Date: Wed, 31 Jan 2024 18:38:20 -0600 Subject: [PATCH 1/5] Drop support for SQLAlchemy 1.1, 1.2 and 1.3 --- requirements-tests.txt | 2 +- tests/test_sqlalchemy.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 2cc75280..6a2a575e 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 764518e5..cd86ac37 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 From d63073c3bbf9881bfd1470e2777a7f992a883489 Mon Sep 17 00:00:00 2001 From: Ricardo Madriz Date: Wed, 31 Jan 2024 18:38:41 -0600 Subject: [PATCH 2/5] Add support for Flask-SQLAlchemy >=3.1 --- mixer/backend/flask.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mixer/backend/flask.py b/mixer/backend/flask.py index d22a79e4..359d8cb3 100644 --- a/mixer/backend/flask.py +++ b/mixer/backend/flask.py @@ -44,7 +44,12 @@ 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: + # https://github.com/pallets-eco/flask-sqlalchemy/issues/698#issuecomment-1250351168 + db = app.extensions['sqlalchemy'].db + except AttributeError: + + db = app.extensions['sqlalchemy'] self.params['session'] = db.session # register extension with app From 49c826baf0950c02787a5541b0e10d4925edaf02 Mon Sep 17 00:00:00 2001 From: Ricardo Madriz Date: Wed, 31 Jan 2024 18:38:55 -0600 Subject: [PATCH 3/5] Bump version --- Changelog | 7 +++++-- mixer/__init__.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 81c93c92..865842f7 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,8 @@ +2024-01-31 + * Drop support for SQLALchemy 1.1, 1.2 and 1.3 2022-03-23 - * Django: Support for UUIDField + * Add support for SQLALchemy >=2.0 + * Add support for Flask-SQLAlchemy >=3.1 2021-10-13 * Support latest libraries @@ -174,7 +177,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 263218f2..6e611a56 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" From 4fb95aa5e5c735a3afebf814cd08b0b87371f31b Mon Sep 17 00:00:00 2001 From: Ricardo Madriz Date: Wed, 31 Jan 2024 18:41:09 -0600 Subject: [PATCH 4/5] Fix Changelog --- Changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 865842f7..c9da93ba 100644 --- a/Changelog +++ b/Changelog @@ -1,9 +1,11 @@ 2024-01-31 * Drop support for SQLALchemy 1.1, 1.2 and 1.3 -2022-03-23 * Add support for SQLALchemy >=2.0 * Add support for Flask-SQLAlchemy >=3.1 +2022-03-23 + * Django: Support for UUIDField + 2021-10-13 * Support latest libraries * Marshmallow: support Dict and Raw fields From 41d4ffe8ff8b6169e57fe34b1abfaf871f6ab94f Mon Sep 17 00:00:00 2001 From: Ricardo Madriz Date: Wed, 31 Jan 2024 18:42:14 -0600 Subject: [PATCH 5/5] Move PR comment link to relevant section --- mixer/backend/flask.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mixer/backend/flask.py b/mixer/backend/flask.py index 359d8cb3..1f9cc857 100644 --- a/mixer/backend/flask.py +++ b/mixer/backend/flask.py @@ -45,10 +45,9 @@ def init_app(self, app): assert app.extensions and app.extensions[ 'sqlalchemy'], "Flask-SQLAlchemy must be inialized before Mixer." try: - # https://github.com/pallets-eco/flask-sqlalchemy/issues/698#issuecomment-1250351168 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