lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Add required fields #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be helpful to be able to programmatically add some constraints to
Couchdb data. The Python schema classes provide a nice place to do this.

Attached is a patch that adds an optional "required" parameter to fields.
When set to True, all instances must be created with a value for that field
(whether loaded from a database or created manually). When created manually
the initial value must be passed during construction. This also works with
default values as you would expect.

If this patch (or something like it) is accepted I'll also create a similar
patch that lets you specify an "options" parameter for fields that will
constrain values to only those values.

Original issue reported on code.google.com by schi...@gmail.com on 12 Jun 2008 at 3:43

Attachments:

GoogleCodeExporter commented 8 years ago
Oh, and this patch requires the patch I submitted in bug #14. I found the 
problem
explained in bug #14 while working on this feature.

Original comment by schi...@gmail.com on 12 Jun 2008 at 3:51

GoogleCodeExporter commented 8 years ago
isn't validation planned for the CouchDB server itself. Then a second validation
would add confusion I think.

Original comment by gdam...@gmail.com on 10 Sep 2008 at 11:37

GoogleCodeExporter commented 8 years ago
Also, validation isn't really the job of the DB access library. I think it's 
more
pertinent if you either a) talk to the guys over at CouchDB about this, or b) 
write a
layer on top of CouchDB/Python which affords things like schema and validation 
(which
defeat the point of using CouchDB entirely).

Original comment by crack...@gmail.com on 17 Dec 2008 at 12:03

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It would be fine if this was done in CouchDB itself, but there was no sign of 
that
feature when I submitted this patch. 

I strongly disagree that adding validation "defeats the point of CouchDB 
entirely".
Sure CouchDB lacks a formal schema and is malleable, but that doesn't mean 
users will
never have a plan for what their data looks like at any given moment. The 
schema-free
bit just lets people change their mind without major hassles. If having any 
form or
schema was bad, then you could argue that this entire access library is 
defeating the
purpose of CouchDB since it has things like typed fields.

Original comment by schi...@gmail.com on 17 Dec 2008 at 12:38

GoogleCodeExporter commented 8 years ago

Original comment by djc.ochtman on 14 Dec 2009 at 10:30

GoogleCodeExporter commented 8 years ago
This seems related to something I would like to see in couchdb: namespaces.
Although I still see no reason to include any kind of enforcement or validation 
in the 
db itself.

See: https://issues.apache.org/jira/browse/COUCHDB-714

Original comment by DeviantR...@gmail.com on 21 May 2010 at 4:43

GoogleCodeExporter commented 8 years ago
A validate_doc_update function in your design do is the way to do this sort of 
validation, http://wiki.apache.org/couchdb/Document_Update_Validation. That 
will work for non-schema (now called mapping) documents too.

Original comment by matt.goo...@gmail.com on 8 Jul 2010 at 8:46