1 package # hide from PAUSE
6 DBIx::Class::Test::SQLite - Base class for running Class::DBI tests against DBIx::Class compat layer, shamelessly ripped from Class::DBI::Test::SQLite
10 use base 'DBIx::Class::Test::SQLite';
12 __PACKAGE__->set_table('test');
13 __PACKAGE__->columns(All => qw/id name film salary/);
17 id INTEGER PRIMARY KEY,
26 This provides a simple base class for DBIx::Class::CDBICompat tests using
27 SQLite. Each class for the test should inherit from this, provide a
28 create_sql() method which returns a string representing the SQL used to
29 create the table for the class, and then call set_table() to create the
30 table, and tie it to the class.
43 eval { require DBIx::Class::CDBICompat }
44 or plan skip_all => 'Class::DBI required for this test';
47 use base qw/DBIx::Class/;
49 __PACKAGE__->load_components(qw/CDBICompat Core DB/);
51 my $DB = DBICTest->_sqlite_dbfilename;
52 my @DSN = ("dbi:SQLite:dbname=$DB", '', '', { AutoCommit => 1, RaiseError => 1 });
54 __PACKAGE__->connection(@DSN);
55 __PACKAGE__->set_sql(_table_pragma => 'PRAGMA table_info(__TABLE__)');
56 __PACKAGE__->set_sql(_create_me => 'CREATE TABLE __TABLE__ (%s)');
57 __PACKAGE__->storage->dbh->do("PRAGMA synchronous = OFF");
63 __PACKAGE__->set_table('test');
65 This combines creating the table with the normal DBIx::Class table()
71 my ($class, $table) = @_;
72 $class->table($table);
73 $class->_create_test_table;
76 sub _create_test_table {
78 my @vals = $class->sql__table_pragma->select_row;
79 $class->sql__create_me($class->create_sql)->execute unless @vals;
84 This is an abstract method you must override.
88 id INTEGER PRIMARY KEY,
95 This should return, as a text string, the schema for the table represented
100 sub create_sql { die "create_sql() not implemented by $_[0]\n" }