Skip Menu |
 

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 35380
Status: new
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: jason [...] froebe.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.09000
Fixed in: 0.09000



Subject: SQL::Translator::Parser::DBI::Sybase fails when sp_helpindex is empty
Download (untitled) / with headers
text/plain 2.8k
Centos 5 Linux dba-dev1 2.6.22.9-default #1 SMP Mon Oct 1 11:26:48 CDT 2007 i686 athlon i386 GNU/Linux Perl v5.8.8 built for i386-linux-thread-multi SQL::Translator::0.09000 Sybase ASE's sp_helpindex will normally return a result set containing the column "INDEX_NAME" which parse() requires. When no index exists, sp_helpindex returns a error string similar to "Object does not have any indexes." but no result set. The following workaround simply wraps the selectall_hash with an eval, if the eval results in no error, then try to use the hash. Sybase_orig.pm Sybase_new.pm 252,259c252,259 < my $h = $dbh->selectall_hashref("sp_helpindex < $table_info->{TABLE_NAME}", 'INDEX_NAME'); < foreach (values %{$h}) { < my $fields = $_->{'INDEX_KEYS'}; < $fields =~ s/\s*//g; < my $i = $table->add_index( < name => < $_->{INDEX_NAME}, --- Show quoted text
> my $h; > eval { $h = $dbh->selectall_hashref("sp_helpindex
$table_info->{TABLE_NAME}", 'INDEX_NAME') }; Show quoted text
> unless ($@) { > foreach (values %{$h}) { > my $fields = $_->{'INDEX_KEYS'}; > $fields =~ s/\s*//g; > my $i = $table->add_index( > name =>
$_->{INDEX_NAME}, 262,263c262,263 < if ($_->{'INDEX_DESCRIPTION'} =~ /unique/i) { < $i->type('unique'); --- Show quoted text
> if ($_->{'INDEX_DESCRIPTION'} =~ /unique/i) { > $i->type('unique');
265,276c265,277 < # we could make this a primary key if there < # isn't already one defined and if there < # aren't any nullable columns in thisindex. < < if (!defined($table->primary_key())) { < $table->primary_key($fields) < unless grep { < $table->get_field($_)->is_nullable() < } split(/,\s*/, $fields); < } < } < } --- Show quoted text
> # we could make this a primary key if there > # isn't already one defined and if there > # aren't any nullable columns in thisindex. > > if (!defined($table->primary_key())) { > $table->primary_key($fields) > unless grep { > $table->get_field($_)->is_nullable() > } split(/,\s*/, $fields); > } > } > } > }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.