Last active
August 29, 2015 14:20
-
-
Save exodist/ef08a3c406d98c1bb618 to your computer and use it in GitHub Desktop.
smallest mongo+test-simple script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Test::More 'no_plan'; | |
use MongoDB::Timestamp; # needed if db is being run as master | |
use MongoDB; | |
use lib "t/lib"; | |
use MongoDBTest qw/build_client get_test_db/; | |
my $conn = build_client(); | |
my $testdb = get_test_db($conn); | |
$testdb->drop; | |
my $dbname = $testdb->name; | |
my $coll = $conn->ns("$dbname.test_collection"); | |
$coll->ensure_index({"x.y" => 1}, {"name" => "foo"}); | |
ok(1); | |
my ($index) = grep { $_->{name} eq 'foo' } $coll->get_indexes; | |
ok(1); | |
__END__ | |
Ways to make the problem go away: | |
ok(1); | |
my ($index) = grep { $_->{name} eq 'foo' } $coll->get_indexes; | |
$index = undef | |
ok(1); | |
ok(1); | |
{ | |
my ($index) = grep { $_->{name} eq 'foo' } $coll->get_indexes; | |
} | |
ok(1); | |
ok(1); | |
grep { $_->{name} eq 'foo' } $coll->get_indexes; | |
ok(1); |
What about a temporary array to hold the result of $coll->get_indexes
? Will that also make the problem go away?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As the MongoDB module is involved, could you post the $VERSION or the commit of MongoDB?