use warnings;
use parent qw(DBIx::Class::ResultSource::View);
use Method::Signatures::Simple;
-use Carp::Always;
use Carp::Clan qw/^DBIx::Class/;
use aliased 'DBIx::Class::ResultSource::Table';
use aliased 'DBIx::Class::ResultClass::HashRefInflator';
push(@all_parents, $super_view) if defined($super_view);
my @sources = ($table, @all_parents);
my @body_cols = map body_cols($_), @sources;
+
+ # Order body_cols to match the columns order.
+ # Must match or you get typecast errors.
+ my %body_cols = map { $_->{name} => $_ } @body_cols;
+ @body_cols =
+ map { $body_cols{$_} }
+ grep { defined $body_cols{$_} }
+ $self->columns;
my @pk_cols = pk_cols $self;
+ # Grab sequence from root table. Only works with one PK named id...
+ # TBD: fix this so it's more flexible.
+ for my $pk_col (@pk_cols) {
+ $self->columns_info->{ $pk_col->{name} }->{sequence} =
+ $self->root_table->name . '_id_seq';
+ }
+
# SELECT statement
my $am_root = !($super_view || @other_parents);
use Test::More qw(no_plan);
use Test::Exception;
use NoSequenceSalad;
+use Devel::Dwarn;
BEGIN {
- $ENV{DBIC_TRACE} = 0;
+ $ENV{DBIC_TRACE} = 0;
}
my ( $dsn, $user, $pass )
= @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
my $schema = NoSequenceSalad->connect( $dsn, $user, $pass );
$schema->storage->ensure_connected;
+$schema->storage->dbh->{Warn} = 0;
$schema->storage->_use_insert_returning(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 } );
+
+lives_ok { $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ) }
+"I can deploy the schema";
isa_ok(
$schema->source('Mesclun'),
lives_ok {
$bowl_of_salad = $schema->resultset('Mesclun')
- ->create( { acidity => 4, spiciness => '10', fresh => 0 } );
+ ->create( { acidity => 4, spiciness => '10', fresh => 0, } );
}
"I can call a create on a view mesclun";
"I can do it for the other view, too";
my $sqlt_object = $schema->{sqlt};
+
+#diag Dwarn $sqlt_object;
is_deeply(
[ map { $_->name } $sqlt_object->get_views ],
[ qw/
- salad
+ salad
mesclun
/
],
__PACKAGE__->set_primary_key('id');
-#__PACKAGE__->has_many(
- #'bars',
- #'LoadTest::Result::Bar',
- #{ 'foreign.b' => 'self.id' }
-#);
+__PACKAGE__->has_many(
+ 'bars',
+ 'LoadTest::Result::Bar',
+ { 'foreign.b' => 'self.id' }
+);
1;
id => {
data_type => 'integer',
is_auto_increment => 1,
- sequence => 'foo_id_seq'
},
words => { data_type => 'text' }
);
["NoSequenceSalad::Result::Salad"] );
__PACKAGE__->result_source_instance->add_additional_parent(
NoSequenceSalad::Result::Dressing->result_source_instance );
-__PACKAGE__->add_columns( "spiciness", { data_type => "integer" } );
+
+__PACKAGE__->add_columns(
+ spiciness => { data_type => "integer" },
+);
1;
"id",
{ data_type => "integer",
is_auto_increment => 1,
- #sequence => '_salad_id_seq',
+ #sequence => '_salad_id_seq',
},
"fresh",
{ data_type => "boolean", },