mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #11964 -- Made constraint support check respect required_db_features.
This will notably silence the warnings issued when running the test suite on MySQL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
2fb872e56f
commit
8b3e1b6e9e
@@ -6,7 +6,8 @@ from django.db.utils import DatabaseError
|
||||
from django.test import TransactionTestCase, skipUnlessDBFeature
|
||||
|
||||
from .models import (
|
||||
Article, ArticleReporter, City, Comment, Country, District, Reporter,
|
||||
Article, ArticleReporter, CheckConstraintModel, City, Comment, Country,
|
||||
District, Reporter,
|
||||
)
|
||||
|
||||
|
||||
@@ -241,19 +242,22 @@ class IntrospectionTests(TransactionTestCase):
|
||||
self.assertEqual(details['check'], check)
|
||||
self.assertEqual(details['foreign_key'], foreign_key)
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
constraints = connection.introspection.get_constraints(cursor, Comment._meta.db_table)
|
||||
# Test custom constraints
|
||||
custom_constraints = {
|
||||
'article_email_pub_date_uniq',
|
||||
'email_pub_date_idx',
|
||||
}
|
||||
if (
|
||||
connection.features.supports_column_check_constraints and
|
||||
connection.features.can_introspect_check_constraints
|
||||
):
|
||||
custom_constraints.add('up_votes_gte_0_check')
|
||||
assertDetails(constraints['up_votes_gte_0_check'], ['up_votes'], check=True)
|
||||
with connection.cursor() as cursor:
|
||||
constraints = connection.introspection.get_constraints(cursor, Comment._meta.db_table)
|
||||
if (
|
||||
connection.features.supports_column_check_constraints and
|
||||
connection.features.can_introspect_check_constraints
|
||||
):
|
||||
constraints.update(
|
||||
connection.introspection.get_constraints(cursor, CheckConstraintModel._meta.db_table)
|
||||
)
|
||||
custom_constraints.add('up_votes_gte_0_check')
|
||||
assertDetails(constraints['up_votes_gte_0_check'], ['up_votes'], check=True)
|
||||
assertDetails(constraints['article_email_pub_date_uniq'], ['article_id', 'email', 'pub_date'], unique=True)
|
||||
assertDetails(constraints['email_pub_date_idx'], ['email', 'pub_date'], index=True)
|
||||
# Test field constraints
|
||||
|
||||
Reference in New Issue
Block a user