6 use dbixcsl_common_tests;
8 my $dbd_interbase_dsn = $ENV{DBICTEST_FIREBIRD_DSN} || '';
9 my $dbd_interbase_user = $ENV{DBICTEST_FIREBIRD_USER} || '';
10 my $dbd_interbase_password = $ENV{DBICTEST_FIREBIRD_PASS} || '';
12 my $odbc_dsn = $ENV{DBICTEST_FIREBIRD_ODBC_DSN} || '';
13 my $odbc_user = $ENV{DBICTEST_FIREBIRD_ODBC_USER} || '';
14 my $odbc_password = $ENV{DBICTEST_FIREBIRD_ODBC_PASS} || '';
18 my $tester = dbixcsl_common_tests->new(
20 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
22 my ($table, $col) = @_;
24 qq{ CREATE GENERATOR gen_${table}_${col} },
26 CREATE TRIGGER ${table}_bi FOR $table
27 ACTIVE BEFORE INSERT POSITION 0
30 IF (NEW.$col IS NULL) THEN
31 NEW.$col = GEN_ID(gen_${table}_${col},1);
36 auto_inc_drop_cb => sub {
37 my ($table, $col) = @_;
39 qq{ DROP TRIGGER ${table}_bi },
40 qq{ DROP GENERATOR gen_${table}_${col} },
44 loader_options => { unquoted_ddl => 1 },
45 connect_info => [ ($dbd_interbase_dsn ? {
46 dsn => $dbd_interbase_dsn,
47 user => $dbd_interbase_user,
48 password => $dbd_interbase_password,
49 connect_info_opts => { on_connect_call => 'use_softcommit' },
54 password => $odbc_password,
64 my $dbh = $schema->storage->dbh;
66 # create a mixed case table
69 CREATE TABLE "Firebird_Loader_Test1" (
70 "Id" INTEGER NOT NULL PRIMARY KEY,
71 "Foo" INTEGER DEFAULT 42
75 CREATE GENERATOR "Gen_Firebird_Loader_Test1_Id"
78 CREATE TRIGGER "Firebird_Loader_Test1_BI" for "Firebird_Loader_Test1"
79 ACTIVE BEFORE INSERT POSITION 0
82 IF (NEW."Id" IS NULL) THEN
83 NEW."Id" = GEN_ID("Gen_Firebird_Loader_Test1_Id",1);
88 my $guard = Scope::Guard->new(\&cleanup_extra);
90 $schema->_loader->{unquoted_ddl} = 0;
91 $schema->_loader->_setup;
93 local $SIG{__WARN__} = sub {};
97 ok ((my $rsrc = eval { $schema->resultset('FirebirdLoaderTest1')->result_source }),
98 'got rsrc for mixed case table');
100 ok ((my $col_info = eval { $rsrc->column_info('Id') }),
101 'got column_info for column Id');
103 is $col_info->{accessor}, 'id', 'column Id has lowercase accessor "id"';
105 is $col_info->{is_auto_increment}, 1, 'is_auto_increment detected for mixed case trigger';
107 is $col_info->{sequence}, 'Gen_Firebird_Loader_Test1_Id', 'correct mixed case sequence name';
109 is eval { $rsrc->column_info('Foo')->{default_value} }, 42, 'default_value detected for mixed case column';
114 if (not ($dbd_interbase_dsn || $odbc_dsn)) {
115 $tester->skip_tests('You need to set the DBICTEST_FIREBIRD_DSN, _USER and _PASS and/or the DBICTEST_FIREBIRD_ODBC_DSN, _USER and _PASS environment variables');
118 # get rid of stupid warning from InterBase/GetInfo.pm
119 if ($dbd_interbase_dsn) {
120 local $SIG{__WARN__} = sub {};
121 require DBD::InterBase;
122 require DBD::InterBase::GetInfo;
124 $tester->run_tests();
128 $schema->storage->disconnect;
129 my $dbh = $schema->storage->dbh;
132 'DROP TRIGGER "Firebird_Loader_Test1_BI"',
133 'DROP GENERATOR "Gen_Firebird_Loader_Test1_Id"',
134 'DROP TABLE "Firebird_Loader_Test1"',
136 eval { $dbh->do($stmt) };