From: John Napiorkowski Date: Wed, 24 Jan 2007 17:58:59 +0000 (+0000) Subject: -- Fixed tabs to spaces issue X-Git-Tag: v0.08010~150^2~98 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eda28767c55e79a4bfca922e36a4b2227155f7e0;p=dbsrgits%2FDBIx-Class.git -- Fixed tabs to spaces issue -- got rid of deprecation warning -- removed default postgres credentials, now if you don't have the PG testing env exported than the tests are skipped. -- tests properly pass now. --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 04dd140..61fef77 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -3,7 +3,7 @@ package DBIx::Class::Storage::DBI; use base 'DBIx::Class::Storage'; -use strict; +use strict; use warnings; use DBI; use SQL::Abstract::Limit; @@ -829,8 +829,7 @@ sub _prep_for_execute { sub _execute { my ($self, $op, $extra_bind, $ident, $bind_attributes, @args) = @_; - if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) - { + if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) { $ident = $ident->from(); } @@ -854,9 +853,7 @@ sub _execute { my $rv; if ($sth) { my $time = time(); - $rv = eval { - my $placeholder_index = 1; foreach my $bound (@bind) { @@ -869,13 +866,13 @@ sub _execute { if defined $bind_attributes->{$column_name}; } - foreach my $data (@data) - { + foreach my $data (@data) + { $data = ref $data ? ''.$data : $data; # stringify args $sth->bind_param($placeholder_index, $data, $attributes); - $placeholder_index++; - } + $placeholder_index++; + } } $sth->execute(); }; @@ -935,32 +932,17 @@ sub insert_bulk { ##use Data::Dumper; ##print STDERR Dumper( $data, $sql, [@bind] ); - + if ($sth) { my $time = time(); - - #$rv = eval { - # - # $sth->execute_array({ - - # ArrayTupleFetch => sub { - - # my $values = shift @$data; - # return if !$values; - # return [ @{$values}[@bind] ]; - # }, - - # ArrayTupleStatus => $tuple_status, - # }) - #}; - - ## Get the bind_attributes, if any exist + + ## Get the bind_attributes, if any exist my $bind_attributes = $self->source_bind_attributes($source); - ## Bind the values and execute - $rv = eval { - + ## Bind the values and execute + $rv = eval { + my $placeholder_index = 1; foreach my $bound (@bind) { @@ -972,20 +954,19 @@ sub insert_bulk { $attributes = $bind_attributes->{$column_name} if defined $bind_attributes->{$column_name}; } - - my @data = map { $_->[$data_index] } @$data; + + my @data = map { $_->[$data_index] } @$data; $sth->bind_param_array( $placeholder_index, [@data], $attributes ); $placeholder_index++; } - $sth->execute_array( {ArrayTupleStatus => $tuple_status} ); + $sth->execute_array( {ArrayTupleStatus => $tuple_status} ); - }; + }; if ($@ || !defined $rv) { my $errors = ''; - foreach my $tuple (@$tuple_status) - { + foreach my $tuple (@$tuple_status) { $errors .= "\n" . $tuple->[1] if(ref $tuple); } $self->throw_exception("Error executing '$sql': ".($@ || $errors)); @@ -1052,7 +1033,7 @@ sub source_bind_attributes { my $data_type = $source->column_info($column)->{data_type} || ''; $bind_attributes->{$column} = $self->bind_attribute_by_data_type($data_type) - if $data_type; + if $data_type; } return $bind_attributes; diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 8f0f30d..ea5f6f0 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -62,7 +62,7 @@ sub bind_attribute_by_data_type { my ($self,$data_type) = @_; my $bind_attributes = { - bytea => { pg_type => DBD::Pg::PG_BYTEA }, + bytea => { pg_type => DBD::Pg::PG_BYTEA }, }; if( defined $bind_attributes->{$data_type} ) { diff --git a/t/bindtype_columns.t b/t/bindtype_columns.t index a32e24c..9d0ad92 100644 --- a/t/bindtype_columns.t +++ b/t/bindtype_columns.t @@ -7,18 +7,14 @@ use DBICTest; my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -$dsn = 'dbi:Pg:dbname=postgres;host=localhost' unless $dsn; -$dbuser = 'postgres' unless $dbuser; -$dbpass = 'postgres' unless $dbpass; - plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' unless ($dsn && $dbuser); plan tests => 3; -DBICTest::Schema->compose_connection('PGTest' => $dsn, $dbuser, $dbpass); +my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass); -my $dbh = PGTest->schema->storage->dbh; +my $dbh = $schema->storage->dbh; $dbh->do(qq[ @@ -31,13 +27,13 @@ $dbh->do(qq[ ],{ RaiseError => 1, PrintError => 1 }); -PGTest::Artist->load_components(qw/ +$schema->class('Artist')->load_components(qw/ PK::Auto Core /); -PGTest::Artist->add_columns( +$schema->class('Artist')->add_columns( "media", { @@ -49,12 +45,12 @@ PGTest::Artist->add_columns( # test primary key handling my $big_long_string = 'abcd' x 250000; -my $new = PGTest::Artist->create({ media => $big_long_string }); +my $new = $schema->resultset('Artist')->create({ media => $big_long_string }); ok($new->artistid, "Created a blob row"); is($new->media, $big_long_string, "Set the blob correctly."); -my $rs = PGTest::Artist->find({artistid=>$new->artistid}); +my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid}); is($rs->get_column('media'), $big_long_string, "Created the blob correctly.");