use File::Temp;
use Test::More qw(no_plan);
use Test::Exception;
-#use Devel::Dwarn;
+use Devel::Dwarn;
-BEGIN { use_ok 'MTITest'; }
+BEGIN {
+ use_ok 'MTITest';
+ $ENV{DBIC_TRACE} = 1;
+}
dies_ok { MTITest->source('Foo')->view_definition }
- "Can't generate view def without connected schema";
+"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 $schema = MTITest->connect( 'dbi:Pg:dbname=mti', 'postgres', '' );
+diag(DwarnS $schema);
#diag("MTITest view definition: ", $schema->resultset('Bar')->result_source->view_definition);
-my $dir = "t/sql"; # tempdir(CLEANUP => 0);
+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 } );
-$schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir);
-$schema->deploy({add_drop_table => 1, add_drop_view => 1});
#diag DwarnS $schema->source($_)->view_definition for qw(Foo Bar);
#diag DwarnS $schema->source($_) for qw(Foo Bar);
use Test::More;
use Test::Exception;
use Devel::Dwarn;
-use Carp::Always;
BEGIN {
use_ok 'Cafe';
$ENV{DBIC_TRACE} = 1;
}
-my $schema = Cafe->connect('dbi:Pg:dbname=cafe','postgres','');
+my $schema = Cafe->connect( 'dbi:Pg:dbname=cafe', 'postgres', '' );
+#diag( DwarnS $schema);
-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');
+#diag(Dwarn $schema->source('Sumatra'));
+#diag(ref($schema->source('Sumatra')));
+isa_ok($schema->source('Sumatra'), 'DBIx::Class::ResultSource::View', "My MTI class also");
-#diag(Dwarn $cup->result_source->columns);
-#diag(Dwarn $schema->resultset('Sumatra')->result_source->columns);
+
+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');
+
+diag(Dwarn $cup->result_source->columns);
+diag(Dwarn $schema->resultset('Sumatra')->result_source->columns);
#my $drink = $schema->resultset('Sumatra')->new_result({sweetness => 6, aroma => 'chocolate'});
-#ok($drink, "made new drink OK");
-#$drink->insert;
-#diag(Dwarn $drink->result_source->columns);
+ok($drink, "made new drink OK");
+$drink->insert;
+diag(Dwarn $drink->result_source->columns);
-#diag(Dwarn mro::get_linear_isa $drink);
+diag(Dwarn mro::get_linear_isa $drink);
-#$drink->insert_or_update;
+$drink->insert_or_update;
done_testing;
__PACKAGE__->table('sumatra');
__PACKAGE__->result_source_instance->add_additional_parent(
Cafe::Result::Sugar->result_source_instance );
-
-__PACKAGE__->add_columns(
- "aroma", { data_type => "text" }
-);
+__PACKAGE__->add_columns( "aroma", { data_type => "text" } );
#__PACKAGE__->has_many( 'coffees', 'Cafe::Result::Coffee',
- #{ 'foreign.id' => 'self.id' } );
+#{ 'foreign.id' => 'self.id' } );
1;