Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Django 5.1 #82

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'timgraham/django'
ref: 'snowflake-5.0.x'
ref: 'snowflake-5.1.x'
path: 'django_repo'
- name: Install system packages for Django's Python test dependencies
run: |
Expand Down
24 changes: 2 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
# Changelog

## 5.0.3 - 2024-04-06
## 5.1 - 2024-08-14

* Fixed `EXISTS` subqueries by removing `LIMIT 1` (which Snowflake does not
support) from them.

## 5.0.2 - 2024-02-23

* Fixed data corruption of new model instance IDs. Connection initialization
now sets `NOORDER_SEQUENCE_AS_DEFAULT=False` (after [the default
changed to True](https://docs.snowflake.com/en/release-notes/bcr-bundles/2024_01/bcr-1483)
in behavior change bundle 2024_01) to allow this backend to continue to
retrieve the ID of newly created objects using
`SELECT MAX(pk_name) FROM table_name`.

## 5.0.1 - 2024-02-07

* Fixed crash in `DatabaseIntrospection.get_table_description()` due to
Snowflake adding a column to the output of `DESCRIBE TABLE` in behavior
change bundle 2023_08.

## 5.0 - 2023-12-16

Initial release for Django 5.0.x.
Initial release for Django 5.1.x.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.x:
Django. For example, to get the latest compatible release for Django 5.1.x:

`pip install django-snowflake==5.0.*`
`pip install django-snowflake==5.1.*`

The minor release number of Django doesn't correspond to the minor release
number of django-snowflake. Use the latest minor release of each.
Expand Down Expand Up @@ -96,12 +96,6 @@ if you encounter an issue worth documenting.
could be creating objects at the same time. Further, you should not manually
specify an ID (e.g. `MyModel(id=1)`) when creating an object.

* Snowflake only supports single layer transactions, but Django's `TestCase`
requires that the database supports nested transactions. Therefore, Django's
`TestCase` operates like `TransactionTestCase`, without the benefit of
transactions to speed it up. Starting in Django 5.1, `TestCase` uses
Snowflake's single layer transaction support to give some speed up.

* Due to snowflake-connector-python's [lack of VARIANT support](https://github.com/snowflakedb/snowflake-connector-python/issues/244),
some `JSONField` queries with complex JSON parameters [don't work](https://github.com/Snowflake-Labs/django-snowflake/issues/58).

Expand Down
2 changes: 1 addition & 1 deletion django_snowflake/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '5.0.3'
__version__ = '5.1'

# Check Django compatibility before other imports which may fail if the
# wrong version of Django is installed.
Expand Down
19 changes: 10 additions & 9 deletions django_snowflake/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_slicing_ordering_in_compound = True
supports_subqueries_in_group_by = False
supports_temporal_subtraction = True
# This really means "supports_nested_transactions". Snowflake supports a
# single level of transaction, BEGIN + (ROLLBACK|COMMIT). Multiple BEGINS
# contribute to the current (only) transaction.
supports_transactions = False
supports_transactions = True
# This feature is specific to the Django fork used for testing.
supports_tz_offsets = False
supports_virtual_generated_columns = True
Expand Down Expand Up @@ -135,6 +132,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# needs to operate as:
# WHERE TO_JSON("MODEL_FIELDS_NULLABLEJSONMODEL"."VALUE":bar) IN (PARSE_JSON('["foo", "bar"]'))
'model_fields.test_jsonfield.TestQuerying.test_key_in',
# Invalid argument types for function 'GET': (VARCHAR(14), VARCHAR(3))
'constraints.tests.CheckConstraintTests.test_validate_jsonfield_exact',
'model_fields.test_jsonfield.TestQuerying.test_literal_annotation_filtering',
# This isn't compatible with the SELECT ... FROM VALUES workaround
# for inserting JSON data. In other words, this query doesn't work:
# SELECT parse_json($1) FROM VALUES (DEFAULT);
Expand All @@ -161,6 +161,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# Zero pk validation not added yet.
'backends.tests.MySQLPKZeroTests.test_zero_as_autoval',
'bulk_create.tests.BulkCreateTests.test_zero_as_autoval',
# Snowflake returns 'The Name::42.00000'.
'db_functions.text.test_concat.ConcatTests.test_concat_non_str',
}

django_test_skips = {
Expand Down Expand Up @@ -191,21 +193,16 @@ class DatabaseFeatures(BaseDatabaseFeatures):
'introspection.tests.IntrospectionTests.test_get_constraints_index_types',
'migrations.test_operations.OperationTests.test_add_index',
'migrations.test_operations.OperationTests.test_alter_field_with_index',
'migrations.test_operations.OperationTests.test_alter_index_together',
'migrations.test_operations.OperationTests.test_remove_index',
'migrations.test_operations.OperationTests.test_rename_index',
'migrations.test_operations.OperationTests.test_rename_index_unnamed_index',
'schema.tests.SchemaTests.test_add_remove_index',
'schema.tests.SchemaTests.test_alter_field_add_index_to_integerfield',
'schema.tests.SchemaTests.test_create_index_together',
'schema.tests.SchemaTests.test_index_together',
'schema.tests.SchemaTests.test_index_together_with_fk',
'schema.tests.SchemaTests.test_indexes',
'schema.tests.SchemaTests.test_order_index',
'schema.tests.SchemaTests.test_remove_constraints_capital_letters',
'schema.tests.SchemaTests.test_remove_db_index_doesnt_remove_custom_indexes',
'schema.tests.SchemaTests.test_remove_field_unique_does_not_remove_meta_constraints',
'schema.tests.SchemaTests.test_remove_index_together_does_not_remove_meta_indexes',
'schema.tests.SchemaTests.test_remove_unique_together_does_not_remove_meta_constraints',
'schema.tests.SchemaTests.test_text_field_with_db_index',
},
Expand Down Expand Up @@ -251,6 +248,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
'Snowflake: Window function type [ROW_NUMBER] requires ORDER BY in '
'window specification.': {
'expressions_window.tests.WindowFunctionTests.test_row_number_no_ordering',
'prefetch_related.tests.PrefetchLimitTests.test_empty_order',
},
# https://github.com/Snowflake-Labs/django-snowflake/issues/40
'DatabaseOperations.sequence_reset_sql() must be implemented for this test.': {
Expand All @@ -262,6 +260,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
'db_functions.comparison.test_cast.CastTests.test_cast_to_char_field_with_max_length',
},
'Snowflake does not support nested transactions.': {
'admin_changelist.tests.ChangeListTests.test_list_editable_atomicity',
'admin_inlines.tests.TestReadOnlyChangeViewInlinePermissions.test_add_url_not_allowed',
'admin_views.tests.AdminViewBasicTest.test_disallowed_to_field',
'admin_views.tests.AdminViewPermissionsTest.test_add_view',
Expand Down Expand Up @@ -336,11 +335,13 @@ class DatabaseFeatures(BaseDatabaseFeatures):
},
'assertNumQueries is sometimes off because of the extra queries this '
'backend uses to fetch an object\'s ID.': {
'admin_utils.test_logentry.LogEntryTests.test_log_action_fallback',
'contenttypes_tests.test_models.ContentTypesTests.test_get_for_models_creation',
'force_insert_update.tests.ForceInsertInheritanceTests.test_force_insert_diamond_mti',
'force_insert_update.tests.ForceInsertInheritanceTests.test_force_insert_false',
'force_insert_update.tests.ForceInsertInheritanceTests.test_force_insert_parent',
'force_insert_update.tests.ForceInsertInheritanceTests.test_force_insert_with_grandparent',
'modeladmin.tests.ModelAdminTests.test_log_deletion_fallback',
'model_formsets_regress.tests.FormsetTests.test_extraneous_query_is_not_run',
'model_inheritance.tests.ModelInheritanceTests.test_create_child_no_update',
'model_inheritance.tests.ModelInheritanceTests.test_create_diamond_mti_common_parent',
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ long_description_content_type = text/markdown
classifiers =
Development Status :: 5 - Production/Stable
Framework :: Django
Framework :: Django :: 5.0
Framework :: Django :: 5.1
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Expand All @@ -27,6 +27,7 @@ project_urls =
python_requires = >=3.10
packages = find:
install_requires =
django >= 5.1, < 5.2
snowflake-connector-python >= 3.6.0

[flake8]
Expand Down