fix data_type for identities in MSSQL RT#50523
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_mssql_extra_tests.pm
1 package dbixcsl_mssql_extra_tests;
2
3 use Test::More;
4
5 my $vendor = 'mssql';
6
7 sub vendor {
8     shift;
9     $vendor = shift;
10 }
11
12 sub extra { +{
13     create => [
14         qq{
15             CREATE TABLE [${vendor}_loader_test1.dot] (
16                 id INT IDENTITY NOT NULL PRIMARY KEY,
17                 dat VARCHAR(8)
18             )
19         },
20     ],
21     drop   => [ "[${vendor}_loader_test1.dot]" ],
22     count  => 6,
23     run    => sub {
24         my ($schema, $monikers, $classes) = @_;
25
26 # Test that the table above (with '.' in name) gets loaded correctly.
27         my $vendor_titlecased = "\u\L$vendor";
28
29         ok((my $rs = eval {
30             $schema->resultset("${vendor_titlecased}LoaderTest1Dot") }),
31             'got a resultset');
32
33         ok((my $from = eval { $rs->result_source->from }),
34             'got an $rsrc->from');
35
36         is ref($from), 'SCALAR', '->table is a scalar ref';
37
38         is eval { $$from }, "[${vendor}_loader_test1.dot]",
39             '->table name is correct';
40
41 # Test that identity columns do not have 'identity' in the data_type, and do
42 # have is_auto_increment.
43         my $identity_col_info = $schema->resultset('LoaderTest10')
44             ->result_source->column_info('id10');
45
46         is $identity_col_info->{data_type}, 'int',
47             q{'INT IDENTITY' column has data_type => 'int'};
48
49         is $identity_col_info->{is_auto_increment}, 1,
50             q{'INT IDENTITY' column has is_auto_increment => 1};
51     },
52 }}
53
54 1;