use strict;
use warnings;
use utf8;
+use DBIx::Class::Optional::Dependencies;
use DBIx::Class::Schema::Loader 'make_schema_at';
use DBIx::Class::Schema::Loader::Utils qw/no_warnings slurp_file/;
use Test::More;
q{
create table pg_loader_test10 (
id bigserial primary key,
- eleven_id int,
- foreign key (eleven_id) references pg_loader_test9(id)
+ nine_id int,
+ foreign key (nine_id) references pg_loader_test9(id)
on delete restrict on update set null deferrable
)
},
-
+ q{
+ create view pg_loader_test11 as
+ select * from pg_loader_test1
+ },
+ q{
+ create table pg_loader_test12 (
+ id integer not null,
+ value integer,
+ active boolean,
+ name text
+ )
+ },
+ q{
+ create unique index uniq_id_lc_name on pg_loader_test12 (
+ id, lower(name)
+ )
+ },
+ q{
+ create unique index uniq_uc_name_id on pg_loader_test12 (
+ upper(name), id
+ )
+ },
+ q{
+ create unique index pg_loader_test12_value on pg_loader_test12 (
+ value
+ )
+ },
+ q{
+ create unique index pg_loader_test12_name_active on pg_loader_test12 (
+ name
+ ) where active
+ },
],
pre_drop_ddl => [
'DROP SCHEMA dbicsl_test CASCADE',
'DROP SCHEMA "dbicsl-test" CASCADE',
'DROP SCHEMA "dbicsl.test" CASCADE',
'DROP TYPE pg_loader_test_enum',
+ 'DROP VIEW pg_loader_test11',
],
- drop => [ qw/pg_loader_test1 pg_loader_test2 pg_loader_test9 pg_loader_test10/ ],
- count => 8 + 30 * 2,
+ drop => [ qw/pg_loader_test1 pg_loader_test2 pg_loader_test9 pg_loader_test10 pg_loader_test12/ ],
+ count => 10 + 30 * 2,
run => sub {
my ($schema, $monikers, $classes) = @_;
'long table comment is in DESCRIPTION';
# test on delete/update fk clause introspection
- ok ((my $rel_info = $schema->source('PgLoaderTest10')->relationship_info('eleven')),
+ ok ((my $rel_info = $schema->source('PgLoaderTest10')->relationship_info('nine')),
'got rel info');
is $rel_info->{attrs}{on_delete}, 'RESTRICT',
->has_relationship('pg_loader_test8s');
} 'cross-schema relationship in multi-db_schema';
}
+
+ # test that views are marked as such
+ isa_ok $schema->resultset($monikers->{pg_loader_test11})->result_source, 'DBIx::Class::ResultSource::View',
+ 'views have table_class set correctly';
+
+ is_deeply
+ { $schema->source($monikers->{pg_loader_test12})->unique_constraints },
+ { pg_loader_test12_value => ['value'] },
+ 'unique indexes are dumped correctly';
},
},
);
if( !$dsn || !$user ) {
$tester->skip_tests('You need to set the DBICTEST_PG_DSN, _USER, and _PASS environment variables');
}
+elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg')) {
+ $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg'));
+}
else {
$tester->run_tests();
}