Revision history for Perl extension DBIx::Class::Schema::Loader
+ - fix picking up quoted tables for SQLite, patch from schwern
- validate class/component loader_options to make sure classes
are available before generating the schema
use strict;
+use Test::More;
use lib qw(t/lib);
use dbixcsl_common_tests;
eval { require DBD::SQLite };
my $class = $@ ? 'SQLite2' : 'SQLite';
-{
- my $tester = dbixcsl_common_tests->new(
- vendor => 'SQLite',
- auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT',
- dsn => "dbi:$class:dbname=./t/sqlite_test",
- user => '',
- password => '',
- );
+my $tester = dbixcsl_common_tests->new(
+ vendor => 'SQLite',
+ auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT',
+ dsn => "dbi:$class:dbname=./t/sqlite_test",
+ user => '',
+ password => '',
+ extra => {
+ create => [
+ # 'sqlite_' is reserved, so we use 'extra_'
+ q{
+ CREATE TABLE "extra_loader_test1" (
+ "id" NOT NULL PRIMARY KEY,
+ "value" VARCHAR(100)
+ )
+ }
+ ],
+ drop => [ 'extra_loader_test1' ],
+ count => 2,
+ run => sub {
+ my ($schema, $monikers, $classes) = @_;
- $tester->run_tests();
-}
+ ok ((my $rs = $schema->resultset($monikers->{extra_loader_test1})),
+ 'resultset for quoted table');
+
+ is_deeply [ $rs->result_source->columns ], [ qw/id value/ ],
+ 'retrieved quoted column names from quoted table';
+ },
+ },
+);
+
+$tester->run_tests();
END {
unlink './t/sqlite_test';
my %loader_opts = (
constraint =>
- qr/^(?:\S+\.)?(?:$self->{vendor}_)?loader_test[0-9]+(?!.*_)/i,
+ qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)_)?loader_test[0-9]+(?!.*_)/i,
relationships => 1,
additional_classes => 'TestAdditional',
additional_base_classes => 'TestAdditionalBase',