Firebird: mixed case support (wip)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_mssql_extra_tests.pm
CommitLineData
b1e43108 1package dbixcsl_mssql_extra_tests;
2
80a212f5 3use strict;
4use warnings;
b1e43108 5use Test::More;
d073740e 6use Test::Exception;
b1e43108 7
8sub extra { +{
9 create => [
80a212f5 10 q{
11 CREATE TABLE [mssql_loader_test1.dot] (
b1e43108 12 id INT IDENTITY NOT NULL PRIMARY KEY,
13 dat VARCHAR(8)
14 )
15 },
80a212f5 16 q{
17 CREATE TABLE mssql_loader_test3 (
d073740e 18 id INT IDENTITY NOT NULL PRIMARY KEY
19 )
20 },
80a212f5 21 q{
22 CREATE VIEW mssql_loader_test4 AS
23 SELECT * FROM mssql_loader_test3
d073740e 24 },
25 ],
243c6ebc 26 pre_drop_ddl => [
27 'CREATE TABLE mssql_loader_test3 (id INT IDENTITY NOT NULL PRIMARY KEY)',
28 'DROP VIEW mssql_loader_test4',
29 ],
d073740e 30 drop => [
243c6ebc 31 '[mssql_loader_test1.dot]',
32 'mssql_loader_test3'
b1e43108 33 ],
80a212f5 34 count => 8,
b1e43108 35 run => sub {
36 my ($schema, $monikers, $classes) = @_;
37
d89bca78 38# Test that the table above (with '.' in name) gets loaded correctly.
7cb9244f 39 ok((my $rs = eval {
80a212f5 40 $schema->resultset($monikers->{'[mssql_loader_test1.dot]'}) }),
5c6fb0a1 41 'got a resultset for table with dot in name');
b1e43108 42
43 ok((my $from = eval { $rs->result_source->from }),
5c6fb0a1 44 'got an $rsrc->from for table with dot in name');
b1e43108 45
5c6fb0a1 46 is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
b1e43108 47
80a212f5 48 is eval { $$from }, "[mssql_loader_test1.dot]",
5c6fb0a1 49 '->table with dot in name has correct name';
50
d89bca78 51# Test that identity columns do not have 'identity' in the data_type, and do
52# have is_auto_increment.
80a212f5 53 my $identity_col_info = $schema->resultset($monikers->{loader_test10})
d89bca78 54 ->result_source->column_info('id10');
55
56 is $identity_col_info->{data_type}, 'int',
57 q{'INT IDENTITY' column has data_type => 'int'};
58
59 is $identity_col_info->{is_auto_increment}, 1,
60 q{'INT IDENTITY' column has is_auto_increment => 1};
d073740e 61
62# Test that a bad view (where underlying table is gone) is ignored.
243c6ebc 63 my $dbh = $schema->storage->dbh;
80a212f5 64 $dbh->do("DROP TABLE mssql_loader_test3");
d073740e 65
66 my @warnings;
67 {
68 local $SIG{__WARN__} = sub { push @warnings, $_[0] };
69 $schema->rescan;
70 }
80a212f5 71 ok ((grep /^Bad table or view 'mssql_loader_test4'/, @warnings),
d073740e 72 'bad view ignored');
73
74 throws_ok {
80a212f5 75 $schema->resultset($monikers->{mssql_loader_test4})
d073740e 76 } qr/Can't find source/,
77 'no source registered for bad view';
b1e43108 78 },
79}}
80
811;