} : ()),
],
loader_options => { preserve_case => 1 },
+ default_is_deferrable => 1,
+ default_on_clause => 'RESTRICT',
data_types => {
# http://infocenter.sybase.com/help/topic/com.sybase.help.sqlanywhere.11.0.1/dbreference_en11/rf-datatypes.html
#
'ntext' => { data_type => 'ntext' },
},
extra => {
- count => 28 * 2,
+ create => [
+ # 4 through 8 are used for the multi-schema tests
+ q{
+ create table sqlanywhere_loader_test9 (
+ id int identity not null primary key
+ )
+ },
+ q{
+ create table sqlanywhere_loader_test10 (
+ id int identity not null primary key,
+ nine_id int,
+ foreign key (nine_id) references sqlanywhere_loader_test9(id)
+ on delete cascade on update set null
+ )
+ },
+ ],
+ drop => [ qw/sqlanywhere_loader_test9 sqlanywhere_loader_test10/ ],
+ count => 4 + 30 * 2,
run => sub {
SKIP: {
$schema = $_[0];
my $self = $_[3];
+ # test on delete/update fk clause introspection
+ ok ((my $rel_info = $schema->source('SqlanywhereLoaderTest10')->relationship_info('nine')),
+ 'got rel info');
+
+ is $rel_info->{attrs}{on_delete}, 'CASCADE',
+ 'ON DELETE clause introspected correctly';
+
+ is $rel_info->{attrs}{on_update}, 'SET NULL',
+ 'ON UPDATE clause introspected correctly';
+
+ is $rel_info->{attrs}{is_deferrable}, 1,
+ 'is_deferrable defaults to 1';
+
my $connect_info = [@$self{qw/dsn user password/}];
my $dbh = $schema->storage->dbh;
}
catch {
$schemas_created = 0;
- skip "no CREATE USER privileges", 28 * 2;
+ skip "no CREATE USER privileges", 30 * 2;
};
$dbh->do(<<"EOF");
CREATE TABLE dbicsl_test1.sqlanywhere_loader_test5 (
id INT IDENTITY NOT NULL PRIMARY KEY,
value VARCHAR(100),
- four_id INTEGER NOT NULL UNIQUE,
+ four_id INTEGER NOT NULL,
+ CONSTRAINT loader_test5_uniq UNIQUE (four_id),
FOREIGN KEY (four_id) REFERENCES dbicsl_test1.sqlanywhere_loader_test4 (id)
)
EOF
$dbh->do("CREATE USER dbicsl_test2 identified by 'dbicsl'");
$dbh->do(<<"EOF");
+ CREATE TABLE dbicsl_test2.sqlanywhere_loader_test5 (
+ pk INT IDENTITY NOT NULL PRIMARY KEY,
+ value VARCHAR(100),
+ four_id INTEGER NOT NULL,
+ CONSTRAINT loader_test5_uniq UNIQUE (four_id),
+ FOREIGN KEY (four_id) REFERENCES dbicsl_test1.sqlanywhere_loader_test4 (id)
+ )
+EOF
+ $dbh->do(<<"EOF");
CREATE TABLE dbicsl_test2.sqlanywhere_loader_test6 (
id INT IDENTITY NOT NULL PRIMARY KEY,
value VARCHAR(100),
ok $row = $rs->create({ value => 'foo' });
} 'executed SQL on table in schema one';
- $rel_info = try { $rsrc->relationship_info('sqlanywhere_loader_test5') };
+ $rel_info = try { $rsrc->relationship_info('dbicsl_test1_sqlanywhere_loader_test5') };
is_deeply $rel_info->{cond}, {
'foreign.four_id' => 'self.id'
'relationship in schema one';
lives_and {
- ok $rsrc = $test_schema->source('SqlanywhereLoaderTest5');
+ ok $rsrc = $test_schema->source('DbicslTest1SqlanywhereLoaderTest5');
} 'got source for table in schema one';
%uniqs = try { $rsrc->unique_constraints };
is keys %uniqs, 2,
'got unique and primary constraint in schema one';
+ delete $uniqs{primary};
+
+ is_deeply ((values %uniqs)[0], ['four_id'],
+ 'correct unique constraint in schema one');
+
lives_and {
ok $rsrc = $test_schema->source('SqlanywhereLoaderTest6');
} 'got source for table in schema two';
is keys %uniqs, 2,
'got unique and primary constraint in schema two';
+ delete $uniqs{primary};
+
+ is_deeply ((values %uniqs)[0], ['six_id'],
+ 'correct unique constraint in schema two');
+
lives_and {
ok $test_schema->source('SqlanywhereLoaderTest6')
->has_relationship('sqlanywhere_loader_test4');
foreach my $table ('dbicsl_test1.sqlanywhere_loader_test8',
'dbicsl_test2.sqlanywhere_loader_test7',
'dbicsl_test2.sqlanywhere_loader_test6',
+ 'dbicsl_test2.sqlanywhere_loader_test5',
'dbicsl_test1.sqlanywhere_loader_test5',
'dbicsl_test1.sqlanywhere_loader_test4') {
try {