Author: REHSACK
Date: Fri May 21 11:56:06 2010
New Revision: 14001
Modified:
dbi/trunk/lib/DBI/SQL/Nano.pm
Log:
- port drop behaviour from SQL::Statement
- port _map_colnums from SQL::Eval
Modified: dbi/trunk/lib/DBI/SQL/Nano.pm
==============================================================================
--- dbi/trunk/lib/DBI/SQL/Nano.pm (original)
+++ dbi/trunk/lib/DBI/SQL/Nano.pm Fri May 21 11:56:06 2010
@@ -282,7 +282,17 @@
sub DROP ($$$)
{
my ( $self, $data, $params ) = @_;
- my $table = $self->open_tables( $data, 0, 0 );
+
+ my $table;
+ eval { ($table) = $self->open_tables( $data, 0, 1 ); };
+ if ( $self->{ignore_missing_table} and $@ and $@ =~ m/no such (table|file)/i )
+ {
+ return ( -1, 0 );
+ }
+
+ $self->do_err($@) if ($@);
+ return ( -1, 0 ) unless $table;
+
$table->drop($data);
( -1, 0 );
}
@@ -703,6 +713,7 @@
defined( $self->{col_nums} ) and "HASH" eq ref( $self->{col_nums} )
or croak("attrbute 'col_nums' must be defined as a hash");
+ exists( $self->{col_nums} ) or $self->{col_nums} = _map_colnums( $self->{col_names} );
defined( $self->{col_names} ) and "ARRAY" eq ref( $self->{col_names} )
or croak("attrbute 'col_names' must be defined as an array");
@@ -710,6 +721,18 @@
return $self;
}
+sub _map_colnums
+{
+ my $col_names = $_[0];
+ my %col_nums;
+ for my $i ( 0 .. $#$col_names )
+ {
+ next unless $col_names->[$i];
+ $col_nums{ $col_names->[$i] } = $i;
+ }
+ return \%col_nums;
+}
+
sub row() { return $_[0]->{row}; }
sub column($) { return $_[0]->{row}->[ $_[0]->column_num( $_[1] ) ]; }
sub column_num($) { $_[0]->{col_nums}->{ $_[1] }; }
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.