More eyes on Check Constraints

158 views
Skip to first unread message

Ian Foote

unread,
Aug 10, 2017, 2:15:26 PM8/10/17
to django-d...@googlegroups.com
Hi all,

I've been working on https://code.djangoproject.com/ticket/11964 to add
support for Check Constraints to the Django ORM and migrations
framework. My work can be found at
https://github.com/django/django/pull/7615.

I think the functionality is basically there, so what it really needs is
some testing on real-world use-cases and more eyes to suggest any
further simplifications or improvements that may be possible.

Thanks,

Ian

David Sanders

unread,
Aug 13, 2017, 2:15:26 PM8/13/17
to Django developers (Contributions to Django itself)
Hi Ian,

Interestingly enough I'd just recently written https://github.com/rapilabs/django-db-constraints based on Matt Schinckel's idea.  I wrote that because although check constraints are great, I really wanted a way to supply any type of constraint - primarily composite foreign keys.  I don't suppose that this would be a possibility as a future extension of your pull request?

Cheers,
David

Ian Foote

unread,
Aug 13, 2017, 6:40:32 PM8/13/17
to django-d...@googlegroups.com
Hi David,

That's an interesting idea. I haven't thought very deeply about
composite foreign keys myself, so I can't say for certain how easy it
would be to build on top of my work.

I did a quick search for prior discussion about this and found
https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys and
https://code.djangoproject.com/ticket/373. These are probably a good
place to start - I plan to have a good read over the next week.

Your library also looks interesting. I also plan to take a close look to
see if there's anything I can learn from there. I wonder if it's worth
trying to converge our implementations - if my patch lands in Django it
would be great to have a compatible implementation that people can use
on earlier versions.

Thanks,
Ian

On 13/08/17 17:44, David Sanders wrote:
> Hi Ian,
>
> Interestingly enough I'd just recently
> written https://github.com/rapilabs/django-db-constraints based on Matt
> Schinckel's idea. I wrote that because although check constraints are
> great, I really wanted a way to supply any type of constraint -
> primarily composite foreign keys. I don't suppose that this would be a
> possibility as a future extension of your pull request?
>
> Cheers,
> David
>
>
> On Friday, August 11, 2017 at 4:15:26 AM UTC+10, Ian Foote wrote:
>
> Hi all,
>
> I've been working on https://code.djangoproject.com/ticket/11964
> <https://code.djangoproject.com/ticket/11964> to add
> support for Check Constraints to the Django ORM and migrations
> framework. My work can be found at
> https://github.com/django/django/pull/7615
> <https://github.com/django/django/pull/7615>.
>
> I think the functionality is basically there, so what it really
> needs is
> some testing on real-world use-cases and more eyes to suggest any
> further simplifications or improvements that may be possible.
>
> Thanks,
>
> Ian
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-develop...@googlegroups.com
> <mailto:django-develop...@googlegroups.com>.
> To post to this group, send email to django-d...@googlegroups.com
> <mailto:django-d...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/537b284f-400c-45c9-8f3b-91842c83f6d8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/537b284f-400c-45c9-8f3b-91842c83f6d8%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Aymeric Augustin

unread,
Sep 10, 2017, 3:35:19 AM9/10/17
to django-d...@googlegroups.com
Hello,

I reviewed the PR today — better late than never... It's looking good and it would be a great addition to Django 2.0.

The biggest outstanding problem is code duplication in django.db.models.sql.query. Advice from people who know a bit about this module would help a lot. Search for "It may be possible to simplify this further." on https://github.com/django/django/pull/7615 and read from there.

Thanks!

-- 
Aymeric.



--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages