my $comments_table = $table->clone;
$comments_table->name($self->table_comments_table);
- my ($comment) = try { $dbh->selectrow_array(<<"EOF") };
+ my ($comment) =
+ (exists $self->_tables->{$comments_table->sql_name} || undef)
+ && try { $dbh->selectrow_array(<<"EOF") };
SELECT comment_text
FROM @{[ $comments_table->sql_name ]}
WHERE table_name = @{[ $dbh->quote($table->name) ]}
my $comments_table = $table->clone;
$comments_table->name($self->column_comments_table);
- my ($comment) = try { $dbh->selectrow_array(<<"EOF") };
+ my ($comment) =
+ (exists $self->_tables->{$comments_table->sql_name} || undef)
+ && try { $dbh->selectrow_array(<<"EOF") };
SELECT comment_text
FROM @{[ $comments_table->sql_name ]}
WHERE table_name = @{[ $dbh->quote($table->name) ]}
@statements_advanced_sqlite, @statements_inline_rels,
@statements_implicit_rels);
+sub CONSTRAINT {
+ my $self = shift;
+return qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)[_-]?)?loader[_-]?test[0-9]+(?!.*_)/i;
+}
+
sub setup_schema {
my ($self, $connect_info, $expected_count) = @_;
}
my %loader_opts = (
- constraint =>
- qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)[_-]?)?loader[_-]?test[0-9]+(?!.*_)/i,
+ constraint => $self->CONSTRAINT,
result_namespace => RESULT_NAMESPACE,
resultset_namespace => RESULTSET_NAMESPACE,
schema_base_class => 'TestSchemaBaseClass',
# run extra tests
$self->{extra}{run}->($conn, $monikers, $classes, $self) if $self->{extra}{run};
- ## Create a SL from existing $dbh
+ ## Create a dump from an existing $dbh in a transaction
+
+TODO: {
+ local $TODO = 'dumping in a txn is experimental and Pg-only right now'
+ unless $self->{vendor} eq 'Pg';
ok eval {
- my %opts = (
- naming => { ALL => 'v7'},
- use_namespaces => 1,
- debug => $ENV{DBIC_SL_SCHEMA_FROM_DEBUG}||0);
+ my %opts = (
+ naming => 'current',
+ constraint => $self->CONSTRAINT,
+ dump_directory => DUMP_DIR,
+ debug => ($ENV{SCHEMA_LOADER_TESTS_DEBUG}||0)
+ );
- my $guard = $schema_class->txn_scope_guard;
+ my $guard = $conn->txn_scope_guard;
- my $schema_from = DBIx::Class::Schema::Loader::make_schema_at(
- "TestSchemFromAnother", \%opts, [ sub {$schema_class->storage->dbh} ]);
+ my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
+ local $SIG{__WARN__} = sub {
+ $warn_handler->(@_)
+ unless $_[0] =~ RESCAN_WARNINGS
+ || $_[0] =~ /commit ineffective with AutoCommit enabled/; # FIXME
+ };
+
+ my $schema_from = DBIx::Class::Schema::Loader::make_schema_at(
+ "TestSchemaFromAnother", \%opts, [ sub { $conn->storage->dbh } ]
+ );
- $guard->commit;
+ $guard->commit;
- 1 }, 'Making a schema from another schema inside a transaction worked';
+ 1;
+ }, 'Making a schema from another schema inside a transaction worked';
- diag $@ if $@;
+ diag $@ if $@ && (not $TODO);
+}
$self->drop_tables unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};