Subject: | update() does not die where insert() does |
My program dies with the following message:
inserts cannot contain the . character at
/home/awillis/perl5/perlbrew/perls/perl-5.12.4/lib/site_perl/5.12.4/x86_64-linux/MongoDB/Collection.pm
line 296.
But it is successful when doing an update, incluing an upsert:
Show quoted text
> db.users.find()
{ "_id" : ObjectId("500827bb7682ea6dbf806ed2"), "ashleyw@example.com" :
"ashley willis", "USERNAME" : "ashleyw" }
Example program is attached. Disabling strict/warnings/{safe => 1} has
no effect. My understanding is that it should die in all cases.
Subject: | mongobug.pl |
#!/usr/bin/perl
use strict;
use warnings;
use MongoDB;
use MongoDB::OID;
my $conn = MongoDB::Connection->new;
my $db = $conn->tutorial;
my $users = $db->users;
my $id = $users->update({'USERNAME' => 'ashley'}, {'ashley@example.com' => 'ashley willis', 'USERNAME' => 'ashley'}, {upsert => 1, safe => 1});
print "ID $id\n";
my $id = $users->update({'USERNAME' => 'ashley'}, {'ashleyw@example.com' => 'ashley willis', 'USERNAME' => 'ashleyw'}, {safe => 1});
print "ID $id\n";
$id = $users->insert({'ashleywillis@example.com' => 'ashley willis', 'USERNAME' => 'ashleywillis'}, {safe => 1});
# dies: inserts cannot contain the . character at /home/awillis/perl5/perlbrew/perls/perl-5.12.4/lib/site_perl/5.12.4/x86_64-linux/MongoDB/Collection.pm line 296.
print "ID $id\n";