Skip to content

support python2: Use super from builtins and wrap keys() in set() #3

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 django_db_constraints/autodetector.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.db.migrations import operations
from django.db.migrations.autodetector import MigrationAutodetector

from builtins import super
from .operations import AlterConstraints


class MigrationAutodetectorWithDbConstraints(MigrationAutodetector):
db_constraints_operations = []

Expand Down
5 changes: 3 additions & 2 deletions django_db_constraints/operations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from builtins import super
from django.db.migrations.operations.models import ModelOptionOperation


Expand All @@ -24,8 +25,8 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state):
if self.allow_migrate_model(schema_editor.connection.alias, to_model):
from_model = from_state.apps.get_model(app_label, self.name)

to_constraints = getattr(to_model._meta, self.option_name, {}).keys()
from_constraints = getattr(from_model._meta, self.option_name, {}).keys()
to_constraints = set(getattr(to_model._meta, self.option_name, {}).keys())
from_constraints = set(getattr(from_model._meta, self.option_name, {}).keys())

table_operations = tuple(
'DROP CONSTRAINT IF EXISTS {name}'.format(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def readme():

setup(
name='django-db-constraints',
version='0.3.0',
version='0.3.0a',
author='shangxiao',
description='Add database table-level constraints to your Django model\'s Meta',
long_description=readme(),
Expand Down