From 57f957ff117c03716a9de72db908a31f6345aafd Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Wed, 22 May 2024 11:47:17 -0700 Subject: [PATCH 1/7] update supported versions (remove 3.2, 4.0, 4.1) --- azure-pipelines.yml | 99 ++++++++++++--------------------------------- setup.py | 7 ++-- tox.ini | 11 ++--- 3 files changed, 33 insertions(+), 84 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8a22f17d..71a65f1b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,6 +24,16 @@ jobs: strategy: matrix: + Python3.12 - Django 5.1: + python.version: '3.12' + tox.env: 'py312-django51' + Python3.11 - Django 5.1: + python.version: '3.11' + tox.env: 'py311-django51' + Python3.10 - Django 5.1: + python.version: '3.10' + tox.env: 'py310-django51' + Python3.12 - Django 5.0: python.version: '3.12' tox.env: 'py312-django50' @@ -34,6 +44,9 @@ jobs: python.version: '3.10' tox.env: 'py310-django50' + Python3.12 - Django 4.2: + python.version: '3.12' + tox.env: 'py311-django42' Python3.11 - Django 4.2: python.version: '3.11' tox.env: 'py311-django42' @@ -47,43 +60,6 @@ jobs: python.version: '3.8' tox.env: 'py38-django42' - Python3.11 - Django 4.1: - python.version: '3.11' - tox.env: 'py311-django41' - Python3.10 - Django 4.1: - python.version: '3.10' - tox.env: 'py310-django41' - Python 3.9 - Django 4.1: - python.version: '3.9' - tox.env: 'py39-django41' - Python 3.8 - Django 4.1: - python.version: '3.8' - tox.env: 'py38-django41' - - Python3.11 - Django 4.0: - python.version: '3.11' - tox.env: 'py311-django40' - Python3.10 - Django 4.0: - python.version: '3.10' - tox.env: 'py310-django40' - Python 3.9 - Django 4.0: - python.version: '3.9' - tox.env: 'py39-django40' - Python 3.8 - Django 4.0: - python.version: '3.8' - tox.env: 'py38-django40' - - Python3.11 - Django 3.2: - python.version: '3.11' - tox.env: 'py311-django32' - Python 3.9 - Django 3.2: - python.version: '3.9' - tox.env: 'py39-django32' - Python 3.8 - Django 3.2: - python.version: '3.8' - tox.env: 'py38-django32' - - steps: - task: CredScan@3 inputs: @@ -138,6 +114,16 @@ jobs: strategy: matrix: + Python3.12 - Django 5.1: + python.version: '3.12' + tox.env: 'py312-django51' + Python3.11 - Django 5.1: + python.version: '3.11' + tox.env: 'py311-django51' + Python3.10 - Django 5.1: + python.version: '3.10' + tox.env: 'py310-django51' + Python3.12 - Django 5.0: python.version: '3.12' tox.env: 'py312-django50' @@ -148,6 +134,9 @@ jobs: python.version: '3.10' tox.env: 'py310-django50' + Python3.12 - Django 4.2: + python.version: '3.12' + tox.env: 'py311-django42' Python3.11 - Django 4.2: python.version: '3.11' tox.env: 'py311-django42' @@ -161,42 +150,6 @@ jobs: python.version: '3.8' tox.env: 'py38-django42' - Python3.11 - Django 4.1: - python.version: '3.11' - tox.env: 'py311-django41' - Python3.10 - Django 4.1: - python.version: '3.10' - tox.env: 'py310-django41' - Python 3.9 - Django 4.1: - python.version: '3.9' - tox.env: 'py39-django41' - Python 3.8 - Django 4.1: - python.version: '3.8' - tox.env: 'py38-django41' - - Python3.11 - Django 4.0: - python.version: '3.11' - tox.env: 'py311-django40' - Python3.10 - Django 4.0: - python.version: '3.10' - tox.env: 'py310-django40' - Python 3.9 - Django 4.0: - python.version: '3.9' - tox.env: 'py39-django40' - Python 3.8 - Django 4.0: - python.version: '3.8' - tox.env: 'py38-django40' - - Python3.11 - Django 3.2: - python.version: '3.11' - tox.env: 'py311-django32' - Python 3.9 - Django 3.2: - python.version: '3.9' - tox.env: 'py39-django32' - Python 3.8 - Django 3.2: - python.version: '3.8' - tox.env: 'py38-django32' - steps: - task: UsePythonVersion@0 inputs: diff --git a/setup.py b/setup.py index 0c9a712b..17a8fc03 100644 --- a/setup.py +++ b/setup.py @@ -16,11 +16,10 @@ 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.0', - 'Framework :: Django :: 4.1', 'Framework :: Django :: 4.2', 'Framework :: Django :: 5.0', + 'Framework :: Django :: 5.1', + ] this_directory = path.abspath(path.dirname(__file__)) @@ -42,7 +41,7 @@ license='BSD', packages=find_packages(), install_requires=[ - 'django>=3.2,<5.1', + 'django>=4.2,<5.2', 'pyodbc>=3.0', 'pytz', ], diff --git a/tox.ini b/tox.ini index 8a304859..f4de1065 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,9 @@ [tox] envlist = - {py36,py37,py38,py39}-django32, - {py38, py39, py310}-django40, - {py38, py39, py310}-django41, {py38, py39, py310}-django42, - {py310, py311, py312}-django50 + {py310, py311, py312}-django50, + {py310, py311, py312}-django51 + [testenv] allowlist_externals = @@ -18,8 +17,6 @@ deps = coverage==5.5 unittest-xml-reporting - django32: django==3.2.* - django40: django>=4.0a1,<4.1 - django41: django>=4.1a1,<4.2 django42: django>=4.2,<4.3 django50: django>=5.0,<5.1 + django51: django>=5.1a1,<5.2 From 6cf5582484000986afd3a062999b7285719dfbba Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Fri, 24 May 2024 13:19:50 -0700 Subject: [PATCH 2/7] remove index_together support --- mssql/schema.py | 40 +++++++++++++++++++++++------------ testapp/tests/test_indexes.py | 7 +++--- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/mssql/schema.py b/mssql/schema.py index 0eff3d90..a0225d65 100644 --- a/mssql/schema.py +++ b/mssql/schema.py @@ -291,7 +291,7 @@ def alter_unique_together(self, model, old_unique_together, new_unique_together) def _model_indexes_sql(self, model): """ Return a list of all index SQL statements (field indexes, - index_together, Meta.indexes) for the specified model. + index_together (Django 5.0 and below), Meta.indexes) for the specified model. """ if not model._meta.managed or model._meta.proxy or model._meta.swapped: return [] @@ -299,9 +299,10 @@ def _model_indexes_sql(self, model): for field in model._meta.local_fields: output.extend(self._field_indexes_sql(model, field)) - for field_names in model._meta.index_together: - fields = [model._meta.get_field(field) for field in field_names] - output.append(self._create_index_sql(model, fields, suffix="_idx")) + if django_version <= (5, 0): + for field_names in model._meta.index_together: + fields = [model._meta.get_field(field) for field in field_names] + output.append(self._create_index_sql(model, fields, suffix="_idx")) if django_version >= (4, 0): for field_names in model._meta.unique_together: @@ -393,8 +394,17 @@ def _column_generated_sql(self, field): params = () return f"GENERATED ALWAYS AS ({expression_sql}) {persistency_sql}", params - def _alter_field(self, model, old_field, new_field, old_type, new_type, - old_db_params, new_db_params, strict=False): + def _alter_field( + self, + model, + old_field, + new_field, + old_type, + new_type, + old_db_params, + new_db_params, + strict=False, + ): """Actually perform a "physical" (non-ManyToMany) field update.""" # the backend doesn't support altering a column to/from AutoField as @@ -792,10 +802,11 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type, if old_field.db_index and new_field.db_index: index_columns.append([old_field]) else: - for fields in model._meta.index_together: - columns = [model._meta.get_field(field) for field in fields] - if old_field.column in [c.column for c in columns]: - index_columns.append(columns) + if django_version <= (5, 0): + for fields in model._meta.index_together: + columns = [model._meta.get_field(field) for field in fields] + if old_field.column in [c.column for c in columns]: + index_columns.append(columns) if index_columns: for columns in index_columns: create_index_sql_statement = self._create_index_sql(model, columns) @@ -917,10 +928,11 @@ def _delete_indexes(self, model, old_field, new_field): index_columns.append([old_field.column]) elif old_field.null != new_field.null: index_columns.append([old_field.column]) - for fields in model._meta.index_together: - columns = [model._meta.get_field(field).column for field in fields] - if old_field.column in columns: - index_columns.append(columns) + if django_version <= (5, 0): + for fields in model._meta.index_together: + columns = [model._meta.get_field(field).column for field in fields] + if old_field.column in columns: + index_columns.append(columns) for index in model._meta.indexes: columns = [model._meta.get_field(field).column for field in index.fields] diff --git a/testapp/tests/test_indexes.py b/testapp/tests/test_indexes.py index 53e7ec38..ee739b1d 100644 --- a/testapp/tests/test_indexes.py +++ b/testapp/tests/test_indexes.py @@ -115,9 +115,10 @@ def test_correct_indexes_exist(self): expected_index_causes = [] if field.db_index: expected_index_causes.append('db_index=True') - for field_names in model_cls._meta.index_together: - if field.name in field_names: - expected_index_causes.append(f'index_together[{field_names}]') + if VERSION <= (5, 0): + for field_names in model_cls._meta.index_together: + if field.name in field_names: + expected_index_causes.append(f'index_together[{field_names}]') if field._unique and field.null: # This is implemented using a (filtered) unique index (not a constraint) to get ANSI NULL behaviour expected_index_causes.append('unique=True & null=True') From 761eeac2e55695512c3c5b4e25b97d7d9b131c0b Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Thu, 30 May 2024 14:58:24 -0700 Subject: [PATCH 3/7] fix circular import --- testapp/tests/test_multiple_databases.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testapp/tests/test_multiple_databases.py b/testapp/tests/test_multiple_databases.py index e1eb885e..0257134f 100644 --- a/testapp/tests/test_multiple_databases.py +++ b/testapp/tests/test_multiple_databases.py @@ -6,7 +6,7 @@ from django import VERSION from django.core.exceptions import ValidationError from django.db import OperationalError -from django.db.backends.sqlite3.operations import DatabaseOperations +from django.db.backends.base.operations import BaseDatabaseOperations from django.test import TestCase, skipUnlessDBFeature from ..models import BinaryData, Pizza, Topping @@ -14,6 +14,7 @@ if VERSION >= (3, 2): from ..models import TestCheckConstraintWithUnicode +DatabaseOperations = BaseDatabaseOperations @skipUnless( VERSION >= (3, 1), From 77eb32c1873af4af1a30aa48e8bd0fa0151c8a77 Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:35:33 -0700 Subject: [PATCH 4/7] fix deprecated check --- mssql/functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mssql/functions.py b/mssql/functions.py index 2f0fd583..1a5087ee 100644 --- a/mssql/functions.py +++ b/mssql/functions.py @@ -281,7 +281,10 @@ def _get_check_sql(self, model, schema_editor): query = Query(model=model, alias_cols=False) else: query = Query(model=model) - where = query.build_where(self.check) + if VERSION >= (5, 1): + where = query.build_where(self.condition) + else: + where = query.build_where(self.check) compiler = query.get_compiler(connection=schema_editor.connection) sql, params = where.as_sql(compiler, schema_editor.connection) if schema_editor.connection.vendor == 'microsoft': From 36370be2c4bc4f63c79e07b646ab56f8fe663e5d Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:35:48 -0700 Subject: [PATCH 5/7] bump tox version to 5.1b1 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f4de1065..b152abdf 100644 --- a/tox.ini +++ b/tox.ini @@ -19,4 +19,4 @@ deps = django42: django>=4.2,<4.3 django50: django>=5.0,<5.1 - django51: django>=5.1a1,<5.2 + django51: django>=5.1b1,<5.2 From e964553a4ab7156b7f1ee536b94eb66fced85ee8 Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:54:22 -0700 Subject: [PATCH 6/7] bump version to 5.1rc1 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b152abdf..c65a5594 100644 --- a/tox.ini +++ b/tox.ini @@ -19,4 +19,4 @@ deps = django42: django>=4.2,<4.3 django50: django>=5.0,<5.1 - django51: django>=5.1b1,<5.2 + django51: django>=5.1rc1,<5.2 From 3653cdef6e56ac3badc8e0e629c14b972fd63f49 Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:25:49 -0700 Subject: [PATCH 7/7] bump version to 5.1 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c65a5594..58a05790 100644 --- a/tox.ini +++ b/tox.ini @@ -19,4 +19,4 @@ deps = django42: django>=4.2,<4.3 django50: django>=5.0,<5.1 - django51: django>=5.1rc1,<5.2 + django51: django>=5.1,<5.2