From 6c9e7c8f55565f61d57c7ebe8c8f9040ad4f84b4 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 15 Oct 2024 19:26:06 +0100 Subject: [PATCH] Test without sqlalchemy-citext The last sqlalchemy-citext update was in 2021 and it has various compatibility issues. SQLAlchemy now has CITEXT support. --- flask_admin/tests/sqla/test_postgres.py | 8 ++++++-- pyproject.toml | 1 - tox.ini | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flask_admin/tests/sqla/test_postgres.py b/flask_admin/tests/sqla/test_postgres.py index a9cbc30c1..e3b76e679 100644 --- a/flask_admin/tests/sqla/test_postgres.py +++ b/flask_admin/tests/sqla/test_postgres.py @@ -1,4 +1,8 @@ -from citext import CIText +try: + from citext import CIText as CITEXT +except ImportError: + # SQLAlchemy >= 2.0.7, although there is an issue until 2.0.19 + from sqlalchemy.dialects.postgresql import CITEXT # type: ignore[attr-defined] from sqlalchemy import text from sqlalchemy.dialects.postgresql import HSTORE from sqlalchemy.dialects.postgresql import JSON @@ -94,7 +98,7 @@ class CITextModel(postgres_db.Model): id = postgres_db.Column( postgres_db.Integer, primary_key=True, autoincrement=True ) - citext_test = postgres_db.Column(CIText) + citext_test = postgres_db.Column(CITEXT) with postgres_db.engine.begin() as connection: connection.execute(text("CREATE EXTENSION IF NOT EXISTS citext")) diff --git a/pyproject.toml b/pyproject.toml index 952e2c5e2..b18d2260a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ sqlalchemy = [ sqlalchemy-with-utils = [ "Flask-Admin[sqlalchemy]", "sqlalchemy_utils>=0.38.0", - "sqlalchemy-citext>=1.8.0", "colour>=0.1.5", "email_validator>=2", "arrow>=0.13.0", diff --git a/tox.ini b/tox.ini index d141b984c..ca117d1ce 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,7 @@ setenv = AZURE_STORAGE_CONNECTION_STRING = DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1; deps = sqlalchemy1: sqlalchemy<2 + sqlalchemy1: sqlalchemy-citext -r requirements/tests.txt commands_pre = noflaskbabel: pip uninstall -y flask-babel