njlg / perl-rethinkdb

A Pure Perl RethinkDB Driver

Home Page:http://njlg.info/perl-rethinkdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to change db

dwburke opened this issue · comments

Any method of changing from the "test" db to "dev" does not seem to work. I've tried

r->connect("localhost", 32769, "dev")->repl;

and

my $io = Rethinkdb::IO->new->connect("localhost", 32769, "dev")->repl;

and

my $io = Rethinkdb::IO->new;
$io->port(32769);
$io->default_db('dev'); # or $io->use('dev');
$io->connect->repl;

My insert:

my $result = r->table("player")->insert({
name => "Conan",
birth => r->now()
})->run;
print to_json($result->response);

thus far my insert always results in this error in the result object:
["Table test.player does not exist."]

Calling this does work:

r->db('dev')->table('player')->insert()

It's entirely possible that I've missed something obvious, but just in case I haven't, I decided to submit an issue.

Thanks,
Dan.

Thanks for reporting this. Let me try a few things and get back to you. (Maybe something broke in the last couple releases?) I know I usually just do r->db('dev')->table->run to be explicit about what database I want to use, but there should be an easy way to set the default database, too.

Sounds good. I'll explicitly call r->db() in the meantime. Thanks!

Also, what version of RethinkDB are you using?

I'm running the official docker container, which has 2.3.1 https://hub.docker.com/_/rethinkdb/

Yeah, double-checked the dashboard, it's 2.3.1, which looks like the most recent version.

Yep. This is definitely a bug. I wondered about this last time I was playing around with this code.

I just pushed Rethinkdb v0.12 to CPAN. Watch http://search.cpan.org/~njlg/Rethinkdb-0.12/ for it to show up. Let me know if you have any more issues. (I'll leave this open until you get a chance to verify)

That did the trick, thanks!