fluidinfo/fluidinfo.js — Issue #74: When a tag value is undefined in session.update, set it to null
Author: terrycojones
Created: 2012-02-28 03:14:26+00:00
State: open

This is not really a bug, but it's a behavior that could be better defined and a suggestion.

If I call the `update` function (or `tag`, which calls `update`) with a tag value that is `undefined`, the payload that is sent to Fluidinfo looks like this:

```{"queries":[["fluiddb/about=\"fred45\"",{"sally/rating":{}}]]}```

In this case, `sally/rating` had an undefined value in the `options.values` passed to `update`. So Fluidinfo is being asked to update nothing at all.

I think the code should either throw an error or convert the undefined value to be a `null`. To me the latter makes more sense. In which case we need a test for `undefined` in the update function which sets a `null` value.

Somewhat related: the update function could keep track of how many values it is supposed to update, and if it's zero just call the onSuccess function immediately without making a network call. This would allow client code that doesn't know how many values it is actually updating to be more efficient when the number is actually zero. I can open a separate ticket on this if people think it's worth fixing.