1 package # hide from PAUSE
9 DBIx::Class::Test::SQLite - Base class for running Class::DBI tests against DBIx::Class compat layer, shamelessly ripped from Class::DBI::Test::SQLite
13 use base 'DBIx::Class::Test::SQLite';
15 __PACKAGE__->set_table('test');
16 __PACKAGE__->columns(All => qw/id name film salary/);
20 id INTEGER PRIMARY KEY,
29 This provides a simple base class for DBIx::Class::CDBICompat tests using
30 SQLite. Each class for the test should inherit from this, provide a
31 create_sql() method which returns a string representing the SQL used to
32 create the table for the class, and then call set_table() to create the
33 table, and tie it to the class.
37 # adding implicit search criteria to the iterator will alter the test
38 # mechanics - leave everything as-is instead, and hope SQLite won't
40 BEGIN { $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS} = 0 }
44 use base qw/DBIx::Class/;
46 __PACKAGE__->load_components(qw/CDBICompat Core DB/);
48 my $DB = DBICTest->_sqlite_dbfilename;
49 my @DSN = ("dbi:SQLite:dbname=$DB", '', '', { AutoCommit => 1, RaiseError => 1 });
51 __PACKAGE__->connection(@DSN);
52 __PACKAGE__->set_sql(_table_pragma => 'PRAGMA table_info(__TABLE__)');
53 __PACKAGE__->set_sql(_create_me => 'CREATE TABLE __TABLE__ (%s)');
54 __PACKAGE__->storage->dbh->do("PRAGMA synchronous = OFF");
60 __PACKAGE__->set_table('test');
62 This combines creating the table with the normal DBIx::Class table()
68 my ($class, $table) = @_;
69 $class->table($table);
70 $class->_create_test_table;
73 sub _create_test_table {
75 my @vals = $class->sql__table_pragma->select_row;
76 $class->sql__create_me($class->create_sql)->execute unless @vals;
81 This is an abstract method you must override.
85 id INTEGER PRIMARY KEY,
92 This should return, as a text string, the schema for the table represented
97 sub create_sql { die "create_sql() not implemented by $_[0]\n" }