Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Adding empty attributes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas  
View profile   Translate to Translated (View Original)
 More options Nov 16 2011, 1:24 am
From: Thomas <thomm...@gmx.net>
Date: Tue, 15 Nov 2011 22:24:10 -0800 (PST)
Local: Wed, Nov 16 2011 1:24 am
Subject: Adding empty attributes
Hi,

I am wondering if and why it's standard behavior that couchdb-python
is adding empty attributes of an object to couchdb. I am just feeling
when an attribute (e.g. name) is None, then it would not end up in the
DB. As i understood CouchDB is returning null for non-existing and
empty attributes anyway.

This way attributes could maybe assigned to a doc dynamically. (Some
docs have it, some not, ...)

Maybe I am thinking into the absolute wrong direction.

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Goodall  
View profile   Translate to Translated (View Original)
 More options Nov 16 2011, 4:29 am
From: Matt Goodall <matt.good...@gmail.com>
Date: Wed, 16 Nov 2011 09:29:02 +0000
Local: Wed, Nov 16 2011 4:29 am
Subject: Re: Adding empty attributes
On 16 November 2011 06:24, Thomas <thomm...@gmx.net> wrote:

> I am wondering if and why it's standard behavior that couchdb-python
> is adding empty attributes of an object to couchdb. I am just feeling
> when an attribute (e.g. name) is None, then it would not end up in the
> DB. As i understood CouchDB is returning null for non-existing and
> empty attributes anyway.

couchdb-python's couchdb.client module doesn't alter attributes (apart
from _id and _rev) at all, it sends whatever the application gives it
to the CouchDB server. For some applications, the absence of an
attribute vs a None value may even be significant. The couchdb.mapping
Document seems to set all its schema attributes to None during
__init__ but that doesn't seem totally unreasonable given that
attribute access has to return *something*.

Like couchdb.client, CouchDB also stores whatever it's given. It's
really just the default JavaScript view engine that treats
JavaScript's undefined as a null. If you need to, you can
differentiate between undefined and null in a map function by using
JS's === strict comparison operator.

> This way attributes could maybe assigned to a doc dynamically. (Some
> docs have it, some not, ...)

Yep, and this is the the behaviour you get with couchb.client already.
There may be an argument for making couchdb.mapping produce sparse
documents but not set and None are still different and I'm not
convinced it would be practical to use if document attributes
disappeared to represent the not set case.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirkjan Ochtman  
View profile   Translate to Translated (View Original)
 More options Nov 16 2011, 4:29 am
From: Dirkjan Ochtman <dirk...@ochtman.nl>
Date: Wed, 16 Nov 2011 10:29:20 +0100
Local: Wed, Nov 16 2011 4:29 am
Subject: Re: Adding empty attributes

On Wed, Nov 16, 2011 at 07:24, Thomas <thomm...@gmx.net> wrote:
> I am wondering if and why it's standard behavior that couchdb-python
> is adding empty attributes of an object to couchdb. I am just feeling
> when an attribute (e.g. name) is None, then it would not end up in the
> DB. As i understood CouchDB is returning null for non-existing and
> empty attributes anyway.

Are you using talking about the mapping layer objects?

I am not sure what the sensible behavior for mapping objects would be.
In JavaScript you would have the difference between undefined and
null, but Python doesn't have that. As such, I don't think it'd be a
good idea to skip the attributes that are None, but I agree that it's
a bit ugly.

Unless you're talking about the client layer of couchdb-python, where
you're talking about item keys instead of attributes, and leaving out
the key vs. setting it to None seems to communicate the intent
trivially.

Cheers,

Dirkjan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas  
View profile  
 More options Nov 16 2011, 5:08 am
From: Thomas <thomm...@gmx.net>
Date: Wed, 16 Nov 2011 02:08:13 -0800 (PST)
Local: Wed, Nov 16 2011 5:08 am
Subject: Re: Adding empty attributes
Sorry, I thing I was a bit confused about couchdb.client and
couchdb.mapping module. It's getting more clear now thanks to both of
your help.

I think I am then talking about the mapping module, that's what I am
using and what produces a lot of "empty" (None) values in couchDB.
After your explanations I understand that it might make sense to know
the difference between a not existing key and an empty one.

You are right, I compared this behavior with the standard js view
engine.

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »