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

Compatibility with Django 3 #80

Merged
merged 1 commit into from
Sep 22, 2021
Merged

Conversation

xavier-lr
Copy link
Contributor

Context removed since Django 3

Subject: Avoid errors of missing argument 'context'

Feature or Bugfix

  • Bugfix

Purpose

  • Avoid following error on Django 3:
    convert_uuidfield_value() missing 1 required positional argument: 'context'

Detail

  • You can reproduce the issue setting UUID field on Django 3, saving the object and then loading it again.

Relates

  • None

@shimizukawa
Copy link
Member

Thanks!

I checked the history of this problem to validate the fix.
First, the convert_uuidfield_value was introduced in PR #24, around the time of Django-1.11. Postgres supports the uuid type, but Redshift treats it as a string. This django-redshift-backend is based on the postgres backend, so it doesn't have uuid support. I guess the PR #24 is based on MySQL's uuid support code: https://github.com/django/django/blob/1.11/django/db/backends/mysql/operations.py#L242-L245

At the same time, the context argument was removed from Django itself on django/django#8709 then this fix is reflected in Django 2.0. This means that anyone using the uuid type in django-redshift-backend after Django 2.0 was affected (I was not using the uuid type).

Thanks for the nice fix!

@@ -87,7 +87,8 @@ def get_db_converters(self, expression):
converters.append(self.convert_uuidfield_value)
return converters

def convert_uuidfield_value(self, value, expression, connection, context):
def convert_uuidfield_value(self, value, expression, connection,
context=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove context argument completely because context has been removed since django 2.0 and django-redshift-backend already drop support django 1.x.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context removed !

Fix issue for anyone using uuid tpye after Django 2.0
Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #80 (a88efdf) into master (d15682d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #80   +/-   ##
=======================================
  Coverage   47.01%   47.01%           
=======================================
  Files           3        3           
  Lines         251      251           
  Branches       62       62           
=======================================
  Hits          118      118           
  Misses        123      123           
  Partials       10       10           
Impacted Files Coverage Δ
django_redshift_backend/base.py 43.40% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d15682d...a88efdf. Read the comment docs.

@shimizukawa shimizukawa merged commit fc0337e into jazzband:master Sep 22, 2021
shimizukawa added a commit that referenced this pull request Sep 22, 2021
@shimizukawa
Copy link
Member

I'm going to release 2.1.0 in this week.

@shimizukawa
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants