From: Matt S Trout Date: Fri, 27 Jan 2006 18:27:34 +0000 (+0000) Subject: Fixed in-place compose_connection. Thanks to dwc for the tests. X-Git-Tag: v0.05005~87 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50041f3c86fb362e7ed38369801fbbfe6ee8b2b1;p=dbsrgits%2FDBIx-Class.git Fixed in-place compose_connection. Thanks to dwc for the tests. --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 787a018..69b48d3 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -241,6 +241,7 @@ sub compose_connection { $class->mk_classdata(resultset_instance => $source->resultset); $class->mk_classdata(class_resolver => $self); } + $self->connection(@info); return $self; } diff --git a/t/30dbicplain.t b/t/30dbicplain.t new file mode 100644 index 0000000..b0546b3 --- /dev/null +++ b/t/30dbicplain.t @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +eval 'use Catalyst::Model::DBIC::Plain; 1' + or plan skip_all => 'Install Catalyst::Model::DBIC::Plain to run this test'; +plan tests => 1; + +use lib qw(t/lib); +use DBICTest::Plain; + +cmp_ok(DBICTest::Plain->resultset('Test')->count, '>', 0, 'count is valid'); diff --git a/t/lib/DBICTest/Plain.pm b/t/lib/DBICTest/Plain.pm new file mode 100644 index 0000000..b4e8428 --- /dev/null +++ b/t/lib/DBICTest/Plain.pm @@ -0,0 +1,33 @@ +package DBICTest::Plain; + +use strict; +use warnings; +use base qw/Catalyst::Model::DBIC::Plain/; +use DBI; + +my $db_file = "t/var/Plain.db"; + +unlink($db_file) if -e $db_file; +unlink($db_file . "-journal") if -e $db_file . "-journal"; +mkdir("t/var") unless -d "t/var"; + +my $dsn = "dbi:SQLite:${db_file}"; + +__PACKAGE__->load_classes; +my $schema = __PACKAGE__->compose_connection(__PACKAGE__, $dsn); + +my $dbh = DBI->connect($dsn); + +my $sql = <do($_) for split(/\n\n/, $sql); + +1; diff --git a/t/lib/DBICTest/Plain/Test.pm b/t/lib/DBICTest/Plain/Test.pm new file mode 100644 index 0000000..4b5e00f --- /dev/null +++ b/t/lib/DBICTest/Plain/Test.pm @@ -0,0 +1,17 @@ +package DBICTest::Plain::Test; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->table('test'); +__PACKAGE__->add_columns( + 'id' => { + data_type => 'integer', + is_auto_increment => 1 + }, + 'name' => { + data_type => 'varchar', + }, +); +__PACKAGE__->set_primary_key('id'); + +1;