njlg / perl-rethinkdb

A Pure Perl RethinkDB Driver
http://njlg.info/perl-rethinkdb
Artistic License 2.0
22 stars 5 forks source link

If database is specified in connect+repl, table_list method cannot be located #26

Closed jdrab closed 8 years ago

jdrab commented 8 years ago

Hi, I don't know if this is really a bug or I'm doing something wrong but I would like to use table_list method with repl. It looks like i have to specify database even though i did it in connect method.

this code does work.

#!/usr/bin/perl
use warnings;
use strict;

use Rethinkdb;
use Data::Dumper;

r->connect('192.168.4.69', 28015)->repl;

my @tables = r->db('test')->table_list()->run();
print Dumper(\@tables);

but this doesn't work (Can't locate object method "table_list" via package "Rethinkdb")

#!/usr/bin/perl
use warnings;
use strict;

use Rethinkdb;
use Data::Dumper;

# i would like to list tables from database 'test'
r->connect('192.168.4.69', 28015,'test')->repl;

my @tables = r->table_list()->run();
print Dumper(\@tables);

what I tried is basically to copy-paste method table_list from Rethinkdb::Query::Database into Rethinkdb.pm and it worked.

I just wanted to know if this is desired behavior and i have to call db before doing table_list() or is it really a bug?

njlg commented 8 years ago

I try to provide a similar API as the official drivers and, for whatever reason, it looks like you have to specify which database you want to list the tables on (http://rethinkdb.com/api/python/#table_list).

I believe there use to be a r->table_list method but it got removed from the official drivers and I removed it from this one.

On 5/17/2016 1:00 AM, Ján Dráb wrote:

Hi, I don't know if this is really a bug or I'm doing something wrong but I would like to use |table_list| method with |repl|. It looks like i have to specify database even though i did it in |connect| method.

this code does work.

!/usr/bin/perl

use warnings; use strict;

use Rethinkdb; use Data::Dumper;

r->connect('192.168.4.69', 28015)->repl;

my @tables = r->db('test')->table_list()->run(); print Dumper(\@tables);

but this doesn't work (Can't locate object method "table_list" via package "Rethinkdb")

!/usr/bin/perl

use warnings; use strict;

use Rethinkdb; use Data::Dumper;

i would like to list tables from database 'test'

r->connect('192.168.4.69', 28015,'test')->repl;

my @tables = r->table_list()->run(); print Dumper(\@tables);

what I tried is basically to copy-paste method |table_list| from |Rethinkdb::Query::Database| into |Rethinkdb.pm| and it worked.

I just wanted to know if this is desired behavior and i have to call |db| before doing table_list() or is it really a bug?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/njlg/perl-rethinkdb/issues/26

jdrab commented 8 years ago

Thank you @njlg I understand. It's not a bug. Please close this 'issue'.