From deb587f63b845459cf0c9ddbe69455100e48d2f4 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 30 Aug 2024 19:35:32 -0400 Subject: [PATCH 1/2] Update to Django 5.2 --- .github/workflows/tests.yml | 3 ++- CHANGELOG.md | 4 ++-- README.md | 4 ++-- django_snowflake/__init__.py | 2 +- django_snowflake/features.py | 8 ++++++++ django_snowflake/introspection.py | 11 ++++++++--- setup.cfg | 4 ++-- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d546d34..2421955 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v4 with: repository: 'timgraham/django' - ref: 'snowflake-5.1.x' + ref: 'snowflake-5.2.x' path: 'django_repo' - name: Install system packages for Django's Python test dependencies run: | @@ -43,6 +43,7 @@ jobs: backends basic bulk_create + composite_pk dates datetimes db_functions diff --git a/CHANGELOG.md b/CHANGELOG.md index da86cb5..58e39c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Changelog -## 5.1 - 2024-08-14 +## 5.2 - Unreleased -Initial release for Django 5.1.x. +Initial release for Django 5.2.x. diff --git a/README.md b/README.md index f60877c..98dd7fc 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ## Install and usage Use the version of django-snowflake that corresponds to your version of -Django. For example, to get the latest compatible release for Django 5.1.x: +Django. For example, to get the latest compatible release for Django 5.2.x: -`pip install django-snowflake==5.1.*` +`pip install django-snowflake==5.2.*` The minor release number of Django doesn't correspond to the minor release number of django-snowflake. Use the latest minor release of each. diff --git a/django_snowflake/__init__.py b/django_snowflake/__init__.py index 791468f..18fa3c0 100644 --- a/django_snowflake/__init__.py +++ b/django_snowflake/__init__.py @@ -1,4 +1,4 @@ -__version__ = '5.1' +__version__ = '5.2a0' # Check Django compatibility before other imports which may fail if the # wrong version of Django is installed. diff --git a/django_snowflake/features.py b/django_snowflake/features.py index 5440eac..ba48f0a 100644 --- a/django_snowflake/features.py +++ b/django_snowflake/features.py @@ -164,6 +164,11 @@ class DatabaseFeatures(BaseDatabaseFeatures): 'bulk_create.tests.BulkCreateTests.test_zero_as_autoval', # Snowflake returns 'The Name::42.00000'. 'db_functions.text.test_concat.ConcatTests.test_concat_non_str', + # To debug (wrong results): + # https://github.com/django/django/commit/b28438f379049e5ee1a89067e9cc14b7d0da07c + "model_fields.test_jsonfield.TestQuerying.test_lookups_special_chars", + # SQL compilation error: syntax error line 1 at position 279 unexpected 'MODEL_FIELDS_NULLABLEJSONMODEL'. + "model_fields.test_jsonfield.TestQuerying.test_lookups_special_chars_double_quotes", } django_test_skips = { @@ -176,6 +181,8 @@ class DatabaseFeatures(BaseDatabaseFeatures): 'Snowflake does not enforce UNIQUE constraints.': { 'auth_tests.test_basic.BasicTestCase.test_unicode_username', 'auth_tests.test_migrations.ProxyModelWithSameAppLabelTests.test_migrate_with_existing_target_permission', + 'composite_pk.tests.CompositePKTests.test_error_on_comment_pk_conflict', + 'composite_pk.tests.CompositePKTests.test_error_on_user_pk_conflict', 'constraints.tests.UniqueConstraintTests.test_database_constraint', 'contenttypes_tests.test_operations.ContentTypeOperationsTests.test_content_type_rename_conflict', 'contenttypes_tests.test_operations.ContentTypeOperationsTests.test_existing_content_type_rename', @@ -238,6 +245,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): 'expressions.tests.FTimeDeltaTests.test_date_subquery_subtraction', 'expressions.tests.FTimeDeltaTests.test_datetime_subquery_subtraction', 'expressions_window.tests.WindowFunctionTests.test_subquery_row_range_rank', + 'foreign_object.test_tuple_lookups.TupleLookupsTests.test_in_subquery', 'lookup.tests.LookupQueryingTests.test_filter_subquery_lhs', 'lookup.tests.LookupTests.test_nested_outerref_lhs', 'model_fields.test_jsonfield.TestQuerying.test_nested_key_transform_on_subquery', diff --git a/django_snowflake/introspection.py b/django_snowflake/introspection.py index 36dff42..817845f 100644 --- a/django_snowflake/introspection.py +++ b/django_snowflake/introspection.py @@ -71,9 +71,14 @@ def get_constraints(self, cursor, table_name): } # Primary keys cursor.execute(f'SHOW PRIMARY KEYS IN TABLE {table_name}') - for row in cursor.fetchall(): - constraints[self.identifier_converter(row[6])] = { - 'columns': [self.identifier_converter(row[4])], + # Sort by key_sequence so columns appear in the correct order. + pk_rows = sorted(cursor.fetchall(), key=lambda row: row[5]) + if pk_rows: + columns = [self.identifier_converter(row[4]) for row in pk_rows] + # Constraint names are all the same. Use the first one. + constraint_name = self.identifier_converter(pk_rows[0][6]) + constraints[constraint_name] = { + 'columns': columns, 'primary_key': True, 'unique': False, 'foreign_key': None, diff --git a/setup.cfg b/setup.cfg index e2e5a0f..a66f17b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,7 @@ long_description_content_type = text/markdown classifiers = Development Status :: 5 - Production/Stable Framework :: Django - Framework :: Django :: 5.1 + Framework :: Django :: 5.2 License :: OSI Approved :: MIT License Operating System :: OS Independent Programming Language :: Python @@ -27,7 +27,7 @@ project_urls = python_requires = >=3.10 packages = find: install_requires = - django >= 5.1, < 5.2 +# django >= 5.1, < 5.2 snowflake-connector-python >= 3.6.0 [flake8] From c79d0081d98ea4430f4f1053d7bf3fe1b385d3bc Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 30 Nov 2021 20:45:04 -0500 Subject: [PATCH 2/2] Add more Django test apps to CI --- .github/workflows/{tests.yml => tests1.yml} | 31 +++---- .github/workflows/tests2.yml | 74 +++++++++++++++++ .github/workflows/tests3.yml | 92 +++++++++++++++++++++ .github/workflows/tests4.yml | 92 +++++++++++++++++++++ 4 files changed, 268 insertions(+), 21 deletions(-) rename .github/workflows/{tests.yml => tests1.yml} (76%) create mode 100644 .github/workflows/tests2.yml create mode 100644 .github/workflows/tests3.yml create mode 100644 .github/workflows/tests4.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests1.yml similarity index 76% rename from .github/workflows/tests.yml rename to .github/workflows/tests1.yml index 2421955..0ee49b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests1.yml @@ -1,11 +1,11 @@ -name: Tests +name: Tests I on: pull_request: paths: - '**.py' - '!setup.py' - - '.github/workflows/tests.yml' + - '.github/workflows/tests1.yml' jobs: django-tests: @@ -37,27 +37,16 @@ jobs: - name: Run the tests run: > python3 django_repo/tests/runtests.py --settings snowflake_settings -v 2 + admin_changelist + admin_custom_urls + admin_docs + admin_filters + admin_inlines + admin_ordering + admin_utils + admin_views aggregation aggregation_regress - annotations - backends - basic - bulk_create - composite_pk - dates - datetimes - db_functions - expressions - expressions_window - field_defaults - inspectdb - introspection - lookup - migrations - model_fields - queries - schema - timezones env: SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} diff --git a/.github/workflows/tests2.yml b/.github/workflows/tests2.yml new file mode 100644 index 0000000..3ee81db --- /dev/null +++ b/.github/workflows/tests2.yml @@ -0,0 +1,74 @@ +name: Tests II + +on: + pull_request: + paths: + - '**.py' + - '!setup.py' + - '.github/workflows/tests2.yml' + +jobs: + django-tests: + runs-on: ubuntu-latest + name: Django Test Suite + steps: + - name: Checkout django-snowflake + uses: actions/checkout@v4 + - name: Checkout Django + uses: actions/checkout@v4 + with: + repository: 'timgraham/django' + ref: 'snowflake-5.2.x' + path: 'django_repo' + - name: Install system packages for Django's Python test dependencies + run: | + sudo apt-get update + sudo apt-get install libmemcached-dev + - name: Install Django and its Python test dependencies + run: | + pip3 install -U pip + cd django_repo/tests/ + pip3 install -e .. + pip3 install -r requirements/py3.txt + - name: install the django-snowflake backend + run: pip3 install . + - name: Copy the test settings file + run: cp .github/workflows/snowflake_settings.py django_repo/tests/ + - name: Run the tests + run: > + python3 django_repo/tests/runtests.py --settings snowflake_settings -v 2 + annotations + auth_tests + backends + basic + bulk_create + cache + check_framework + composite_pk + constraints + contenttypes_tests + custom_columns + custom_lookups + custom_managers + custom_methods + custom_pk + datatypes + dates + datetimes + db_functions + db_typecasts + db_utils + defer + defer_regress + delete + delete_regress + empty + expressions + expressions_case + expressions_window + extra_regress + env: + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }} diff --git a/.github/workflows/tests3.yml b/.github/workflows/tests3.yml new file mode 100644 index 0000000..513884f --- /dev/null +++ b/.github/workflows/tests3.yml @@ -0,0 +1,92 @@ +name: Tests III + +on: + pull_request: + paths: + - '**.py' + - '!setup.py' + - '.github/workflows/tests3.yml' + +jobs: + django-tests: + runs-on: ubuntu-latest + name: Django Test Suite + steps: + - name: Checkout django-snowflake + uses: actions/checkout@v4 + - name: Checkout Django + uses: actions/checkout@v4 + with: + repository: 'timgraham/django' + ref: 'snowflake-5.2.x' + path: 'django_repo' + - name: Install system packages for Django's Python test dependencies + run: | + sudo apt-get update + sudo apt-get install libmemcached-dev + - name: Install Django and its Python test dependencies + run: | + pip3 install -U pip + cd django_repo/tests/ + pip3 install -e .. + pip3 install -r requirements/py3.txt + - name: install the django-snowflake backend + run: pip3 install . + - name: Copy the test settings file + run: cp .github/workflows/snowflake_settings.py django_repo/tests/ + - name: Run the tests + run: > + python3 django_repo/tests/runtests.py --settings snowflake_settings -v 2 + field_defaults + field_subclassing + file_storage + file_uploads + filtered_relation + force_insert_update + foreign_object + forms_tests + from_db_value + generic_inline_admin + generic_relations + generic_relations_regress + generic_views + get_earliest_or_latest + get_object_or_404 + get_or_create + i18n + inline_formsets + inspectdb + introspection + invalid_models_tests + known_related_objects + lookup + m2m_and_m2o + m2m_intermediary + m2m_multiple + m2m_recursive + m2m_regress + m2m_signals + m2m_through + m2m_through_regress + m2o_recursive + managers_regress + many_to_many + many_to_one + many_to_one_null + max_lengths + migrate_signals + migrations + migration_test_data_persistence + modeladmin + model_inheritance + model_inheritance_regress + model_meta + model_options + model_package + model_regress + model_fields + env: + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }} diff --git a/.github/workflows/tests4.yml b/.github/workflows/tests4.yml new file mode 100644 index 0000000..9234296 --- /dev/null +++ b/.github/workflows/tests4.yml @@ -0,0 +1,92 @@ +name: Tests IV + +on: + pull_request: + paths: + - '**.py' + - '!setup.py' + - '.github/workflows/tests4.yml' + +jobs: + django-tests: + runs-on: ubuntu-latest + name: Django Test Suite + steps: + - name: Checkout django-snowflake + uses: actions/checkout@v4 + - name: Checkout Django + uses: actions/checkout@v4 + with: + repository: 'timgraham/django' + ref: 'snowflake-5.2.x' + path: 'django_repo' + - name: Install system packages for Django's Python test dependencies + run: | + sudo apt-get update + sudo apt-get install libmemcached-dev + - name: Install Django and its Python test dependencies + run: | + pip3 install -U pip + cd django_repo/tests/ + pip3 install -e .. + pip3 install -r requirements/py3.txt + - name: install the django-snowflake backend + run: pip3 install . + - name: Copy the test settings file + run: cp .github/workflows/snowflake_settings.py django_repo/tests/ + - name: Run the tests + run: > + python3 django_repo/tests/runtests.py --settings snowflake_settings -v 2 + model_forms + model_formsets + model_formsets_regress + multiple_database + mutually_referential + nested_foreign_keys + null_fk + null_fk_ordering + null_queries + one_to_one + ordering + order_with_respect_to + or_lookups + pagination + prefetch_related + properties + proxy_model_inheritance + proxy_models + queries + queryset_pickle + raw_query + reserved_names + reverse_lookup + save_delete_hooks + schema + select_for_update + select_related + select_related_onetoone + select_related_regress + serializers + servers + signals + sitemaps_tests + sites_framework + sites_tests + string_lookup + swappable_models + syndication_tests + test_client + test_client_regress + timezones + transaction_hooks + transactions + unmanaged_models + update + update_only_fields + validation + view_tests + env: + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}