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
@@ -70,14 +70,24 @@ class Comment(models.Model):
|
||||
article = models.ForeignKey(Article, models.CASCADE, db_index=True)
|
||||
email = models.EmailField()
|
||||
pub_date = models.DateTimeField()
|
||||
up_votes = models.PositiveIntegerField()
|
||||
body = models.TextField()
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.CheckConstraint(name='up_votes_gte_0_check', check=models.Q(up_votes__gte=0)),
|
||||
models.UniqueConstraint(fields=['article', 'email', 'pub_date'], name='article_email_pub_date_uniq'),
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=['email', 'pub_date'], name='email_pub_date_idx'),
|
||||
]
|
||||
|
||||
|
||||
class CheckConstraintModel(models.Model):
|
||||
up_votes = models.PositiveIntegerField()
|
||||
|
||||
class Meta:
|
||||
required_db_features = {
|
||||
'supports_table_check_constraints',
|
||||
}
|
||||
constraints = [
|
||||
models.CheckConstraint(name='up_votes_gte_0_check', check=models.Q(up_votes__gte=0)),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user