Re: [Django] #11964: Using database-level CHECK CONSTRAINTS

瀏覽次數:60 次
跳到第一則未讀訊息

Django

未讀,
2012年4月13日 清晨7:59:172012/4/13
收件者:django-...@googlegroups.com
#11964: Using database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.1
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: check contsraint | Someday/Maybe
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by dbrgn):

* cc: dbrgn (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

未讀,
2015年3月16日 中午12:07:232015/3/16
收件者:django-...@googlegroups.com
#11964: Using database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage:

| Someday/Maybe
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:7>

Django

未讀,
2015年5月24日 清晨5:32:462015/5/24
收件者:django-...@googlegroups.com
#11964: Using database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage:
| Someday/Maybe
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by esigra):

* cc: esigra (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:8>

Django

未讀,
2015年8月6日 下午4:20:422015/8/6
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS

-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master

(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* version: 1.1 => master
* stage: Someday/Maybe => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:9>

Django

未讀,
2015年8月10日 中午12:48:432015/8/10
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by gam_phon):

* cc: gam_phon (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:10>

Django

未讀,
2016年5月2日 中午12:15:162016/5/2
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by rrauenza):

Could/should this feature request also handle this case of constraint I
brought up in this thread?

https://code.djangoproject.com/ticket/11964

Basically unique_together doesn't consider a null value unique per SQL
spec -- which makes perfect sense in single column indexes and is extended
to multi column indexes.

So if someone wanted (A, B, NULL) to be a unique row there would need to
be an index built on the first two columns "where <third column> is null"

These SO articles give a better overview:

http://stackoverflow.com/questions/17510261/django-unique-together-
constraint-failure
http://dba.stackexchange.com/questions/9759/postgresql-multi-column-
unique-constraint-and-null-values

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:11>

Django

未讀,
2016年5月6日 上午8:04:202016/5/6
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by alexpirine):

I would also love this feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:12>

Django

未讀,
2016年11月5日 清晨7:10:182016/11/5
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* owner: nobody => Ian Foote
* status: new => assigned
* cc: python@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:13>

Django

未讀,
2017年2月23日 晚上9:41:202017/2/23
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f" 19b2dfd1]:
{{{
#!CommitTicketReference repository=""
revision="19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f"
Refs #11964, #26167 -- Made Expressions deconstructible.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:14>

Django

未讀,
2017年2月23日 晚上9:41:212017/2/23
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"508b5debfb16843a8443ebac82c1fb91f15da687" 508b5deb]:
{{{
#!CommitTicketReference repository=""
revision="508b5debfb16843a8443ebac82c1fb91f15da687"
Refs #11964 -- Made Q objects deconstructible.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:15>

Django

未讀,
2017年2月26日 下午4:12:562017/2/26
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:16>

Django

未讀,
2017年8月15日 晚上11:53:212017/8/15
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ryan Hiebert):

* cc: Ryan Hiebert (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:17>

Django

未讀,
2017年8月21日 清晨6:04:022017/8/21
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Asif Saifuddin Auvi):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:18>

Django

未讀,
2017年10月2日 中午12:50:552017/10/2
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:19>

Django

未讀,
2017年10月22日 下午4:30:452017/10/22
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Luke Plant):

This external project seems to implement this feature:

https://github.com/rapilabs/django-db-constraints

It does some monkey patching that would be unnecessary if this were in
core.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:20>

Django

未讀,
2017年11月4日 上午10:17:532017/11/4
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:21>

Django

未讀,
2017年12月4日 晚上9:39:162017/12/4
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ian Foote):

Now that Django 2 is released, I'd like to see this land. I think I've
resolved all the outstanding issues raised on the pull request before. Is
the next step to rebase/squash my work in progress commits?

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:22>

Django

未讀,
2018年2月4日 清晨5:16:452018/2/4
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Asif Saifuddin Auvi):

* needs_better_patch: 0 => 1


Comment:

conflicts needed to be resolved and squash for final review I believe.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:23>

Django

未讀,
2018年2月4日 下午1:52:232018/2/4
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* needs_better_patch: 1 => 0


Comment:

Conflicts fixed and commits squashed.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:24>

Django

未讀,
2018年3月5日 上午9:02:202018/3/5
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Michael Wheeler):

* cc: Michael Wheeler (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:25>

Django

未讀,
2018年4月3日 中午12:04:222018/4/3
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Asif Saifuddin Auvi):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:26>

Django

未讀,
2018年4月3日 中午12:25:052018/4/3
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 1 => 0


Comment:

Please don't check "Patch needs improvement" only because there's a small
merge conflict (as far as I can see, there's no outstanding review
comments on the patch).

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:27>

Django

未讀,
2018年5月16日 上午11:30:412018/5/16
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Pablo Montepagano):

* cc: Pablo Montepagano (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:28>

Django

未讀,
2018年6月6日 中午12:47:272018/6/6
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check contsraint | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:29>

Django

未讀,
2018年6月17日 凌晨4:40:072018/6/17
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: check constraint | Triage Stage: Ready for

| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ties de Kock):

* keywords: check contsraint => check constraint
* cc: Ties de Kock (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:30>

Django

未讀,
2018年7月10日 下午4:00:162018/7/10
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"952f05a6db2665d83c04075119285f2164b03432" 952f05a6]:
{{{
#!CommitTicketReference repository=""
revision="952f05a6db2665d83c04075119285f2164b03432"
Fixed #11964 -- Added support for database check constraints.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:31>

Django

未讀,
2018年7月20日 下午3:05:402018/7/20
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gavin Wahl):

Is it now possible to define a field that comes with a check constraint,
or can they only be defined at the table level? I'd like to be able to
define my own StrictlyPositiveIntegerField.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:32>

Django

未讀,
2018年9月25日 上午11:15:092018/9/25
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"9a0e0d966a1a317b1b422b5e92949e6d1f33fc2f" 9a0e0d96]:
{{{
#!CommitTicketReference repository=""
revision="9a0e0d966a1a317b1b422b5e92949e6d1f33fc2f"
Refs #11964 -- Renamed a database check constraint test.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:33>

Django

未讀,
2018年10月2日 上午11:12:232018/10/2
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"9142bebff2657f2129a2028137f81d09db989968" 9142bebf]:
{{{
#!CommitTicketReference repository=""
revision="9142bebff2657f2129a2028137f81d09db989968"
Refs #11964 -- Changed CheckConstraint() signature to use keyword-only
arguments.

Also renamed the `constraint` argument to `check` to better represent
which
part of the constraint the provided `Q` object represents.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:34>

Django

未讀,
2018年10月2日 晚上7:16:102018/10/2
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"bc7e288ca9554ac1a0a19941302dea19df1acd21" bc7e288]:
{{{
#!CommitTicketReference repository=""
revision="bc7e288ca9554ac1a0a19941302dea19df1acd21"
Fixed #29745 -- Based Expression equality on detailed initialization
signature.

The old implementation considered objects initialized with an equivalent
signature different if some arguments were provided positionally instead
of
as keyword arguments.

Refs #11964, #26167.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:35>

Django

未讀,
2018年10月18日 上午11:09:592018/10/18
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Scott Stevens):

It appears that adding multiple constraints to a table results in only the
last being stored.

Reviewing the SQL (`./manage.py migrate`), I'm seeing each constraint
being added by way of `ALTER TABLE`, `CREATE TABLE`, `INSERT INTO ...
SELECT`, `DROP TABLE`, however only the most recent constraint is added
each time, so the previous constraint is dropped with the old table when
adding the new one.

Using `38f3de86bd0bfa4c9b57db1237fa55e9fa88bc6e`, Python 3.6.6 (Win10x64)
with SQLite database.

Should I file a new bug for this?

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:36>

Django

未讀,
2018年10月18日 上午11:16:012018/10/18
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

Yeah please file a new ticket Scott and escalate it to release blocker as
it's a bug in a yet unreleased version of Django.

This is probably due to the fact SQLite requires a table rebuild on most
`ALTER TABLE` operations.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:37>

Django

未讀,
2018年10月24日 晚上7:19:492018/10/24
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"32da3cfdf9f25e0a21c0376e94067795380abeae" 32da3cfd]:
{{{
#!CommitTicketReference repository=""
revision="32da3cfdf9f25e0a21c0376e94067795380abeae"
Refs #11964 -- Removed raw SQL from and cleaned up constraint operation
tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:38>

Django

未讀,
2018年10月29日 清晨5:34:362018/10/29
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"95bda03f2da15172cf342f13ba8a77c007b63fbb" 95bda03]:
{{{
#!CommitTicketReference repository=""
revision="95bda03f2da15172cf342f13ba8a77c007b63fbb"
Fixed #29868 -- Retained database constraints on SQLite table rebuilds.

Refs #11964.

Thanks Scott Stevens for testing this upcoming feature and the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:39>

Django

未讀,
2019年1月9日 清晨5:49:002019/1/9
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Balazs Endresz):

> Is it now possible to define a field that comes with a check constraint,
or can they only be defined at the table level? I'd like to be able to
define my own StrictlyPositiveIntegerField.

Looks like positive integer fields have been already defined that way:
https://github.com/django/django/blob/084536a/django/db/models/fields/__init__.py#L637
https://github.com/django/django/blob/084536a/django/db/backends/postgresql/base.py#L95

Similarly, one can add a ''simple'' custom field (that has no additional
arguments):

{{{
class StrictlyPositiveIntegerField(models.PositiveIntegerField):
# NB the db_check method is not documented
def db_check(self, connection):
data = self.db_type_parameters(connection)
return '"%(column)s" > 0' % data
}}}

With a few tweaks it probably could be made to work with custom field args
and CheckConstraints too:

{{{
BaseDatabaseSchemaEditor.sql_create_check = (
# need to drop the check first, otherwise it can't be modified:
'ALTER TABLE %(table)s DROP CONSTRAINT IF EXISTS %(name)s'
'ALTER TABLE %(table)s ADD CONSTRAINT %(name)s CHECK (%(check)s)'
)

class CustomFieldWithArgsAndChecks(models.Field):
... # handle custom args in __init__() and deconstruct() and define
validators too
def db_check(self, connection):
constraint = models.CheckConstraint(check=models.Q(**{
f'{self.name}__gte': self.gte,
f'{self.name}__lte': self.lte,
}), name='')
with connection.schema_editor() as schema_editor:
return constraint._get_check_sql(self.model, schema_editor)
}}}

I wonder if there are any plans to officially support doing that kind of
thing in the future.
Perhaps it isn't too far out of reach now with CheckConstraints in place.

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:40>

Django

未讀,
2019年8月12日 凌晨1:22:492019/8/12
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8b3e1b6e9e4ee87fe85b2e5437faf59457e03e62" 8b3e1b6]:
{{{
#!CommitTicketReference repository=""
revision="8b3e1b6e9e4ee87fe85b2e5437faf59457e03e62"
Refs #11964 -- Made constraint support check respect required_db_features.

This will notably silence the warnings issued when running the test
suite on MySQL.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:41>

Django

未讀,
2019年11月21日 清晨6:26:462019/11/21
收件者:django-...@googlegroups.com
#11964: Add the ability to use database-level CHECK CONSTRAINTS
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: check constraint | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"306b6875209cfedce2536a6679e69adee7c9bc6a" 306b6875]:
{{{
#!CommitTicketReference repository=""
revision="306b6875209cfedce2536a6679e69adee7c9bc6a"
Refs #11964 -- Removed SimpleCol in favor of Query(alias_cols).

This prevent having to pass simple_col through multiple function calls
by defining whether or not references should be resolved with aliases
at the Query level.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11964#comment:42>

回覆所有人
回覆作者
轉寄
0 則新訊息