6 # use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else
8 if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) {
9 unshift @INC, $_ for split /:/, $lib_dirs;
14 use dbixcsl_common_tests;
16 my $dbd_sybase_dsn = $ENV{DBICTEST_MSSQL_DSN} || '';
17 my $dbd_sybase_user = $ENV{DBICTEST_MSSQL_USER} || '';
18 my $dbd_sybase_password = $ENV{DBICTEST_MSSQL_PASS} || '';
20 my $odbc_dsn = $ENV{DBICTEST_MSSQL_ODBC_DSN} || '';
21 my $odbc_user = $ENV{DBICTEST_MSSQL_ODBC_USER} || '';
22 my $odbc_password = $ENV{DBICTEST_MSSQL_ODBC_PASS} || '';
24 my $tester = dbixcsl_common_tests->new(
26 auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
27 default_function => 'getdate()',
28 default_function_def => 'DATETIME DEFAULT getdate()',
29 connect_info => [ ($dbd_sybase_dsn ? {
30 dsn => $dbd_sybase_dsn,
31 user => $dbd_sybase_user,
32 password => $dbd_sybase_password,
37 password => $odbc_password,
43 CREATE TABLE [mssql_loader_test1.dot] (
44 id INT IDENTITY NOT NULL PRIMARY KEY,
49 CREATE TABLE mssql_loader_test3 (
50 id INT IDENTITY NOT NULL PRIMARY KEY
54 CREATE VIEW mssql_loader_test4 AS
55 SELECT * FROM mssql_loader_test3
59 'CREATE TABLE mssql_loader_test3 (id INT IDENTITY NOT NULL PRIMARY KEY)',
60 'DROP VIEW mssql_loader_test4',
63 '[mssql_loader_test1.dot]',
68 my ($schema, $monikers, $classes) = @_;
70 # Test that the table above (with '.' in name) gets loaded correctly.
72 $schema->resultset($monikers->{'[mssql_loader_test1.dot]'}) }),
73 'got a resultset for table with dot in name');
75 ok((my $from = eval { $rs->result_source->from }),
76 'got an $rsrc->from for table with dot in name');
78 is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
80 is eval { $$from }, "[mssql_loader_test1.dot]",
81 '->table with dot in name has correct name';
83 # Test that identity columns do not have 'identity' in the data_type, and do
84 # have is_auto_increment.
85 my $identity_col_info = $schema->resultset($monikers->{loader_test10})
86 ->result_source->column_info('id10');
88 is $identity_col_info->{data_type}, 'int',
89 q{'INT IDENTITY' column has data_type => 'int'};
91 is $identity_col_info->{is_auto_increment}, 1,
92 q{'INT IDENTITY' column has is_auto_increment => 1};
94 # Test that a bad view (where underlying table is gone) is ignored.
95 my $dbh = $schema->storage->dbh;
96 $dbh->do("DROP TABLE mssql_loader_test3");
100 local $SIG{__WARN__} = sub { push @warnings, $_[0] };
103 ok ((grep /^Bad table or view 'mssql_loader_test4'/, @warnings),
107 $schema->resultset($monikers->{mssql_loader_test4})
108 } qr/Can't find source/,
109 'no source registered for bad view';
114 if(not ($dbd_sybase_dsn || $odbc_dsn)) {
115 $tester->skip_tests('You need to set the DBICTEST_MSSQL_DSN, _USER and _PASS and/or the DBICTEST_MSSQL_ODBC_DSN, _USER and _PASS environment variables');
118 $tester->run_tests();