From: Norbert Buchmuller Date: Wed, 18 Feb 2009 06:09:36 +0000 (+0100) Subject: * Added new TODO tests for bind attributes (for ->select, ->update, ->delete). X-Git-Tag: v0.08240~107 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1e86b3ece82da60de75f81704a828e1fc30e898;p=dbsrgits%2FDBIx-Class.git * Added new TODO tests for bind attributes (for ->select, ->update, ->delete). --- diff --git a/t/bindtype_columns.t b/t/bindtype_columns.t index 0a3f77d..1462d9b 100644 --- a/t/bindtype_columns.t +++ b/t/bindtype_columns.t @@ -10,7 +10,7 @@ my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/} plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' unless ($dsn && $dbuser); -plan tests => 3; +plan tests => 6; my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); @@ -32,19 +32,57 @@ my $dbh = $schema->storage->dbh; ],{ RaiseError => 1, PrintError => 1 }); } -# test primary key handling -my $big_long_string = 'abcd' x 250000; +my $big_long_string = "\x00\x01\x02 abcd" x 125000; -my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string }); +my $new; +# test inserting a row +{ + $new = $schema->resultset('BindType')->create({ bytea => $big_long_string }); -ok($new->id, "Created a bytea row"); -is($new->bytea, $big_long_string, "Set the blob correctly."); + ok($new->id, "Created a bytea row"); + is($new->bytea, $big_long_string, "Set the blob correctly."); +} -my $rs = $schema->resultset('BindType')->find({ id => $new->id }); +# test retrieval of the bytea column +{ + my $row = $schema->resultset('BindType')->find({ id => $new->id }); + is($row->get_column('bytea'), $big_long_string, "Created the blob correctly."); +} -is($rs->get_column('bytea'), $big_long_string, "Created the blob correctly."); +TODO: { + local $TODO = + 'Passing bind attributes to $sth->bind_param() should be implemented (it only works in $storage->insert ATM)'; + + my $rs = $schema->resultset('BindType')->search({ bytea => $big_long_string }); + + # search on the bytea column (select) + { + my $row = $rs->first; + is($row ? $row->id : undef, $new->id, "Found the row searching on the bytea column."); + } + + # search on the bytea column (update) + { + my $new_big_long_string = $big_long_string . "2"; + $schema->txn_do(sub { + $rs->update({ bytea => $new_big_long_string }); + my $row = $schema->resultset('BindType')->find({ id => $new->id }); + is($row ? $row->get_column('bytea') : undef, $new_big_long_string, + "Updated the row correctly (searching on the bytea column)." + ); + $schema->txn_rollback; + }); + } + + # search on the bytea column (delete) + { + $schema->txn_do(sub { + $rs->delete; + my $row = $schema->resultset('BindType')->find({ id => $new->id }); + is($row, undef, "Deleted the row correctly (searching on the bytea column)."); + $schema->txn_rollback; + }); + } +} $dbh->do("DROP TABLE bindtype_test"); - - -