forked from microsoft/mssql-django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error on unsupported unique constraint conditions
CREATE INDEX in SQL Server only supports AND conditions (not OR) as part of its WHERE syntax. This change handles that situation by raising an error from the schema editor class. This change adds unit tests to confirm this happens against a SQL Server database. Previously opened at ESSolutions/django-mssql-backend#97
- Loading branch information
Showing
4 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Generated by Django 3.1.5 on 2021-01-18 00:05 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('testapp', '0009_test_drop_table_with_foreign_key_reference_part2'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TestUnsupportableUniqueConstraint', | ||
fields=[ | ||
( | ||
'id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID', | ||
), | ||
), | ||
('_type', models.CharField(max_length=50)), | ||
('status', models.CharField(max_length=50)), | ||
], | ||
options={ | ||
'managed': False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='TestSupportableUniqueConstraint', | ||
fields=[ | ||
( | ||
'id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID', | ||
), | ||
), | ||
('_type', models.CharField(max_length=50)), | ||
('status', models.CharField(max_length=50)), | ||
], | ||
), | ||
migrations.AddConstraint( | ||
model_name='testsupportableuniqueconstraint', | ||
constraint=models.UniqueConstraint( | ||
condition=models.Q( | ||
('status', 'in_progress'), | ||
('status', 'needs_changes'), | ||
('status', 'published'), | ||
), | ||
fields=('_type',), | ||
name='and_constraint', | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name='testsupportableuniqueconstraint', | ||
constraint=models.UniqueConstraint( | ||
condition=models.Q(status__in=['in_progress', 'needs_changes']), | ||
fields=('_type',), | ||
name='in_constraint', | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters