You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Paulo Edgar Castro <pa...@gmail.com> on 2012/12/28 23:38:05 UTC

Bad special document member: __VERSION__

Hi all,

I just bumped into this error in the subject.
Upon further digging as per commit 
d748a328aec166047c81bcaf3dec6b0a885a2088, keys starting with an 
underscore are not accepted as valid...

DB="http://127.0.0.1:5984/mydb"
curl -X PUT $DB
curl -H "Content-Type:application/json"  -d 
'{"docs":[{"key":"baz","_name":"bazzel"},{"key":"bar","_name":"barry"}]}' -X 
POST $DB/_bulk_docs

{"error":"doc_validation","reason":"Bad special document member: _name"}

Some modules I'm using as part of a project try to serialize a whole 
class and some of the keys are serialized with underscores.
This means that CouchDB stops being an option for storage.

Is there a good reason for this design decision ?
Couldn't the underscore keys be validated against the set of reserved 
words or similar ?
Could this be something not serving a useful purpose ?

Also, I couldn't find any meaningful caveat about this in the wiki ...

Regards,



                 PECastro


Re: Bad special document member: __VERSION__

Posted by Robert Newson <rn...@apache.org>.
All top-level properties beginning with _ are reserved for internal
uses, but you can put any named property at a deeper level.

On 28 December 2012 22:38, Paulo Edgar Castro
<pa...@gmail.com> wrote:
> Hi all,
>
> I just bumped into this error in the subject.
> Upon further digging as per commit d748a328aec166047c81bcaf3dec6b0a885a2088,
> keys starting with an underscore are not accepted as valid...
>
> DB="http://127.0.0.1:5984/mydb"
> curl -X PUT $DB
> curl -H "Content-Type:application/json"  -d
> '{"docs":[{"key":"baz","_name":"bazzel"},{"key":"bar","_name":"barry"}]}' -X
> POST $DB/_bulk_docs
>
> {"error":"doc_validation","reason":"Bad special document member: _name"}
>
> Some modules I'm using as part of a project try to serialize a whole class
> and some of the keys are serialized with underscores.
> This means that CouchDB stops being an option for storage.
>
> Is there a good reason for this design decision ?
> Couldn't the underscore keys be validated against the set of reserved words
> or similar ?
> Could this be something not serving a useful purpose ?
>
> Also, I couldn't find any meaningful caveat about this in the wiki ...
>
> Regards,
>
>
>
>                 PECastro
>

Re: Bad special document member: __VERSION__

Posted by Keith Gable <zi...@ignition-project.com>.
Easier would be something like { "data": your object here } though.
On Dec 28, 2012 4:52 PM, "Stanley Iriele" <si...@gmail.com> wrote:

> Hey which couchdb version are you using?...is this 1.2? Or later?. I
> noticed that an underscore was used for reserved words so I just  prepend
> some some special characters in its place to avoid that.
>
> On Dec 28, 2012 5:38 PM, "Paulo Edgar Castro" <pa...@gmail.com>
> wrote:
> >
> > Hi all,
> >
> > I just bumped into this error in the subject.
> > Upon further digging as per commit
> d748a328aec166047c81bcaf3dec6b0a885a2088, keys starting with an underscore
> are not accepted as valid...
> >
> > DB="http://127.0.0.1:5984/mydb"
> > curl -X PUT $DB
> > curl -H "Content-Type:application/json"  -d
> '{"docs":[{"key":"baz","_name":"bazzel"},{"key":"bar","_name":"barry"}]}'
> -X POST $DB/_bulk_docs
> >
> > {"error":"doc_validation","reason":"Bad special document member: _name"}
> >
> > Some modules I'm using as part of a project try to serialize a whole
> class and some of the keys are serialized with underscores.
> > This means that CouchDB stops being an option for storage.
> >
> > Is there a good reason for this design decision ?
> > Couldn't the underscore keys be validated against the set of reserved
> words or similar ?
> > Could this be something not serving a useful purpose ?
> >
> > Also, I couldn't find any meaningful caveat about this in the wiki ...
> >
> > Regards,
> >
> >
> >
> >                 PECastro
> >
>

Re: Bad special document member: __VERSION__

Posted by Stanley Iriele <si...@gmail.com>.
Hey which couchdb version are you using?...is this 1.2? Or later?. I
noticed that an underscore was used for reserved words so I just  prepend
some some special characters in its place to avoid that.

On Dec 28, 2012 5:38 PM, "Paulo Edgar Castro" <pa...@gmail.com>
wrote:
>
> Hi all,
>
> I just bumped into this error in the subject.
> Upon further digging as per commit
d748a328aec166047c81bcaf3dec6b0a885a2088, keys starting with an underscore
are not accepted as valid...
>
> DB="http://127.0.0.1:5984/mydb"
> curl -X PUT $DB
> curl -H "Content-Type:application/json"  -d
'{"docs":[{"key":"baz","_name":"bazzel"},{"key":"bar","_name":"barry"}]}'
-X POST $DB/_bulk_docs
>
> {"error":"doc_validation","reason":"Bad special document member: _name"}
>
> Some modules I'm using as part of a project try to serialize a whole
class and some of the keys are serialized with underscores.
> This means that CouchDB stops being an option for storage.
>
> Is there a good reason for this design decision ?
> Couldn't the underscore keys be validated against the set of reserved
words or similar ?
> Could this be something not serving a useful purpose ?
>
> Also, I couldn't find any meaningful caveat about this in the wiki ...
>
> Regards,
>
>
>
>                 PECastro
>