I think the documentation is out of date on CPAN (I'll cut .40 next
week) and its behavior is what you're looking for. From
http://api.mongodb.org/perl/MongoDB/Collection.html#update%20%28\%25criteria%2c%20\%25object%2c%20\%25options%3f%29:
'Returns 1 unless the safe option is set. If safe is set, this will
return a hash of information about the update, including number of
documents updated (n). If safe is set and the update fails, update will
croak. You can also check if the update succeeded by doing an unsafe
update, then calling MongoDB::Database/"last_error($options?)".'
(api.mongodb.org/perl updates every time there's a commit.)
On Fri Nov 19 11:45:48 2010, abayliss@gmail.com wrote:
Show quoted text> OK, I can understand now why it works as it does, but I still think
> it's a bug. Even if I want the call to update to return 0 if it fails,
> I still may want to know if it updated an existing record. I realise I
> could just not use safe if I might be updating an existing record, but
> it seems wrong to have to special case this.
>
> Either the documentation should change to clarify that you can't get
> at the updatedExisting field (or any other fields that may be returned
> by last_error?) if you pass safe => 1 (which isn't really very
> helpful), or there should be some other way of getting at this data.
>
> Andrew