On Sep 26, 10:27 pm, Tim Chase <django.us...@tim.thechases.com> wrote:
> > Is there anyone else interested in this?
>
> yes, I'd be interested in seeing some sort of database-level
> CHECK constraint as part of Django.  I had been sitting on my
> thoughts until I see the GSoC work done on model-validation wend
> its way towards trunk.  My hope had been to see model validation
> incorporate some DB-level CHECK constraints where feasible.

I did have a brief look at the django-check-constraint project on
google code, but it was overkill for what I needed.

> One of the other difficulties involves database expression
> differences.  For the simple cases such as you suggest, it's not
> as bad as they're fairly standard.  However, when functions are
> involved, each DB seems to have its own family of functions.
> E.g. if you want to assert the length of a string is 10
> characters ("len" vs. "strlen"?) or the time is during business
> hours ("hour(fieldname) between 8 and 17"...extracting
> time-portions varies across DB engines).

Yeah, for the time being I was only interested in simple cases.
Comparing against a static value in the case of column constraints,
and comparing two columns in the table-level case.  I don't even allow
for 'start < finish + 1' in the code I have written so far.

> I currently just add the CHECK constraints manually (well, in
> post-syncdb code).  Having them in a declarative fashion would
> help keep them in the right place.

Not to mention that it will allow the same code to control the db-
level constraint, and the django validation (admin, form).  Which is
DRY, and one of the reasons I am moving projects to django.

I also looked a little bit at south, which I have just started using
for migrations.  It doesn't have anything in there that is that
useful, other than raw SQL.  Which can do those type of things, but it
is nicer to move into the declaration.

Matt.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to