From: Amiri Barksdale at Home Date: Thu, 23 Dec 2010 18:03:50 +0000 (-0800) Subject: Manual workaround for Pg and DBICs default insert_returning behavior. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c296bdb570a33bff89ed04eb199620034261a24;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Manual workaround for Pg and DBICs default insert_returning behavior. Must set schema->storage->_use_insert_returning to 0 manually. --- diff --git a/t/02view_def.t b/t/02view_def.t index 2829ff0..a9a1345 100644 --- a/t/02view_def.t +++ b/t/02view_def.t @@ -8,14 +8,12 @@ use Devel::Dwarn; BEGIN { use_ok 'MTITest'; - #$ENV{DBIC_TRACE} = 1; + $ENV{DBIC_TRACE} = 1; } dies_ok { MTITest->source('Foo')->view_definition } "Can't generate view def without connected schema"; -#my $schema = MTITest->connect('dbi:SQLite::memory:'); - my $schema = MTITest->connect( 'dbi:Pg:dbname=mti', 'postgres', '' ); my $dir = "t/sql"; # tempdir(CLEANUP => 0); diff --git a/t/03cafe.t b/t/03cafe.t deleted file mode 100644 index 005289c..0000000 --- a/t/03cafe.t +++ /dev/null @@ -1,31 +0,0 @@ -use strict; -use warnings; -use lib 't/lib'; -use Test::More qw(no_plan); -use Test::Exception; -use Devel::Dwarn; - -BEGIN { - use_ok 'Cafe'; - #$ENV{DBIC_TRACE} = 1; -} - -my $schema = Cafe->connect( 'dbi:Pg:dbname=cafe', 'postgres', '' ); - -isa_ok($schema->source('Sumatra'), 'DBIx::Class::ResultSource::View', "My MTI class also"); - -#my $dir = "t/sql"; # tempdir(CLEANUP => 0); -#$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); - -#$schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ); - -my $drink = $schema->resultset('Sumatra') - ->create( { sweetness => 4, aroma => 'earthy', flavor => 'great' } ); - -#my $cup = $schema->resultset('Coffee'); - -##my $drink = $schema->resultset('Sumatra')->new_result({sweetness => 6, aroma => 'chocolate'}); -#ok($drink, "made new drink OK"); -#$drink->insert; - -#$drink->insert_or_update; diff --git a/t/03insert.t b/t/03insert.t new file mode 100644 index 0000000..e7271d0 --- /dev/null +++ b/t/03insert.t @@ -0,0 +1,33 @@ +use strict; +use warnings; +use lib 't/lib'; +use Test::More qw(no_plan); +use Test::Exception; +use Devel::Dwarn; + +BEGIN { + use_ok 'Cafe'; + $ENV{DBIC_TRACE} = 1; +} + +my $schema = Cafe->connect( 'dbi:Pg:dbname=cafe', 'postgres', '' ); +$schema->storage->ensure_connected; +$schema->storage->_use_insert_returning(0); +isa_ok( + $schema->source('Sumatra'), + 'DBIx::Class::ResultSource::View', + "My MTI class also" +); + +my ( $drink, $drink1 ); + +lives_ok { + $drink = $schema->resultset('Sumatra') + ->create( { sweetness => 4, aroma => 'earthy', flavor => 'great' } ); +} +"I can call a create on a view sumatra"; + +lives_ok { + $drink1 = $schema->resultset('Coffee')->create( { flavor => 'aaight', } ); +} +"I can do it for the other view, too";