mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Fixed #36808 -- Required name argument in UniqueConstraint signature.
By trading ValueError for TypeError for omitted name arguments, we gain a little clarity.
This commit is contained in:
committed by
Jacob Walls
parent
73c987eb3b
commit
b172cbdf33
1
AUTHORS
1
AUTHORS
@@ -551,6 +551,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Jonas Lundberg <jonas.lundberg@gmail.com>
|
||||
Jonathan Davis <jonathandavis47780@gmail.com>
|
||||
Jonatas C. D. <jonatas.cd@gmail.com>
|
||||
Jonathan Biemond <jonathan.biemond@gmail.com>
|
||||
Jonathan Buchanan <jonathan.buchanan@gmail.com>
|
||||
Jonathan Daugherty (cygnus) <http://www.cprogrammer.org/>
|
||||
Jonathan Feignberg <jdf@pobox.com>
|
||||
|
||||
@@ -265,7 +265,7 @@ class UniqueConstraint(BaseConstraint):
|
||||
self,
|
||||
*expressions,
|
||||
fields=(),
|
||||
name=None,
|
||||
name,
|
||||
condition=None,
|
||||
deferrable=None,
|
||||
include=None,
|
||||
|
||||
@@ -130,7 +130,7 @@ ensures the age field is never less than 18.
|
||||
``UniqueConstraint``
|
||||
====================
|
||||
|
||||
.. class:: UniqueConstraint(*expressions, fields=(), name=None, condition=None, deferrable=None, include=None, opclasses=(), nulls_distinct=None, violation_error_code=None, violation_error_message=None)
|
||||
.. class:: UniqueConstraint(*expressions, fields=(), name, condition=None, deferrable=None, include=None, opclasses=(), nulls_distinct=None, violation_error_code=None, violation_error_message=None)
|
||||
|
||||
Creates a unique constraint in the database.
|
||||
|
||||
|
||||
@@ -1462,7 +1462,7 @@ class UniqueConstraintTests(TestCase):
|
||||
def test_requires_name(self):
|
||||
msg = "A unique constraint must be named."
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
models.UniqueConstraint(fields=["field"])
|
||||
models.UniqueConstraint(fields=["field"], name="")
|
||||
|
||||
def test_database_default(self):
|
||||
models.UniqueConstraint(
|
||||
|
||||
Reference in New Issue
Block a user