Login Register

dojo.data.api.Write - setValues function

In the dojo.data.api.Write declaration, it states for the function setValues that...

// Calling store.setValues(x, y, []) (with *values* as an empty array) has
// the same effect as calling store.unsetAttribute(x, y).

I find that if you pass setValues a blank array, it should NOT have the affect of store.unsertAttribute(x, y).

In my case, I store objects into an ItemFileWriteStore and manipulate them through the use of setValue/setValues. I ran into a case today, where I cleared out an array of data, and went to set the value of it in the store, but the store removed the attribute, which then caused any subsequent queries for data to fail since they were running checks on that particular attribute, which no longer existed.

I know ItemFileWriteStore isn't meant for object-based input/output, but I would also think you'll run into this situation more-so with upcoming stores like JsonPathStore.

What are others' thoughts on this matter?

Thanks in advance for any input! :)

I was thinking that

I was thinking that setValues() would create an empty array and unset would undefine the whole property. That is what I understood to be the distinction and I believe thats how I treated it in jsonPathStore, but I'll have to check. Are you saying that isn't the case?

Dustin Machi

I think that's how it should work...

In my opinion, that's how it should work (what you're implementing) for any data store.

The API is stating (and I'm not trying to say it's right or wrong, just questioning it) that setValues() should have the same affect as calling unsetAttribute() if a blank array is passed. This is how the ItemFileWriteStore works currently.

I just feel that the underlying data-type should be preserved and not deleted unless you explicitly call unsetAttribute() yourself. Such that if the attribute is of type string, you'd get "", if it's of type number, you get 0 (or maybe NaN depending on how it's being used/eval'd on the calling side), and so on and so forth.