Re: the return of tables ()

Tim Bunce <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Mon, Sep 01, 2008 at 03:28:48PM +0200, H.Merijn Brand wrote:
> > > > > 
> > > > > http://search.cpan.org/~timb/DBI-1.607/lib/DBI/DBD.pm#Generating_the_get_info_method
> > > > > 
> > > > > shows the perl command without quotes and parens, so it is completely
> > > > > useless as an example
> > > > > 
> > > > > perl -MDBI::DBD::Metadata -we "write_getinfo_pm (qw{ dbi:ODBC:foo_db username password Driver })"
> > > > > 
> > > > > would be a portable solution to not mix up the quotes on WinShit
> > > > 
> > > > Patches welcome. Want a commit bit (if you don't have one already)?
> > > 
> > > These are the patches I feel comfortable with, as they obviously will
> > > not clash with *opinions*. Is the repo in git? in that case, I'll take
> > > the bit. If it is in svn, I'll pass.
> > 
> > svn, pity.
> 
> OK, patch:

Thanks. Applied.

> > > > > As get_info (29) now returns a TRUE value, the 'tables ()' method is
> > > > > using a different strategy to build the list it returns:
> > > > > 
> > > > >     sub tables
> > > > >     {
> > > > >         my ($dbh, @args) = @_;
> > > > >         my $sth    = $dbh->table_info (@args[0..4]) or return;
> > > > >         my $tables = $sth->fetchall_arrayref or return;
> > > > >         my @tables;
> > > > > »       if ($dbh->get_info (29)) { # SQL_IDENTIFIER_QUOTE_CHAR
> > > > > »           @tables = map { $dbh->quote_identifier (@{$_}[0,1,2]) } @$tables;
> > > > > »           }

> > > > > Unify has no support for CATALOG's, so the values in info are not
> > > > > defined, but still used in the map, causing all my tables no showing up
> > > > > with and empty "". in front of it, which is illegal to the database :(
> > > > 
> > > > Seems like your quote_identifier() method is doing the wrong thing.
> > > > The docs for quote_identifier say:
> > > 
> > > I do not have a quote_identifier () method. I rely on DBI doing the
> > > right thing.
> > 
> > I believe the DBI's quote_identifier does the right thing.
> > 
> > I'd guess that the CATALOG value returned by table_info is an empty
> > string but should be an undef.
> 
> Not defined at all, so I *guess* that is the same as undefined.

I wasn't very clear (and was actually partly misleading). Sorry.

What I meant was that the TABLE_CAT and/or TABLE_SCHEM columns in the
data returned by your table_info() method are probably empty strings but
should be undefs.

What does
    Data::Dumper::Dumper($dbh->table_info(...)->fetchall_arrayref)
show for an example table?

Tim.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.