1 package dbixcsl_mssql_extra_tests;
15 CREATE TABLE [${vendor}_loader_test1.dot] (
16 id INT IDENTITY NOT NULL PRIMARY KEY,
21 CREATE TABLE ${vendor}_loader_test2 (
22 id INT IDENTITY NOT NULL PRIMARY KEY,
23 dat VARCHAR(100) DEFAULT 'foo',
24 num NUMERIC DEFAULT 10.89,
26 ts DATETIME DEFAULT getdate()
30 drop => [ "[${vendor}_loader_test1.dot]", "${vendor}_loader_test2" ],
33 my ($schema, $monikers, $classes) = @_;
35 # Test that the table above (with '.' in name) gets loaded correctly.
36 my $vendor_titlecased = "\u\L$vendor";
39 $schema->resultset("${vendor_titlecased}LoaderTest1Dot") }),
40 'got a resultset for table with dot in name');
42 ok((my $from = eval { $rs->result_source->from }),
43 'got an $rsrc->from for table with dot in name');
45 is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
47 is eval { $$from }, "[${vendor}_loader_test1.dot]",
48 '->table with dot in name has correct name';
50 # Test that column defaults are set correctly
52 $schema->resultset("${vendor_titlecased}LoaderTest2") }),
53 'got a resultset for table with column with default value');
55 my $rsrc = $rs->result_source;
57 is eval { $rsrc->column_info('dat')->{default_value} }, 'foo',
58 'correct default_value for column with literal string default';
60 is eval { $rsrc->column_info('anint')->{default_value} }, 6,
61 'correct default_value for column with literal integer default';
63 cmp_ok eval { $rsrc->column_info('num')->{default_value} },
65 'correct default_value for column with literal numeric default';
67 ok((my $function_default =
68 eval { $rsrc->column_info('ts')->{default_value} }),
69 'got default_value for column with function default');
71 is ref($function_default), 'SCALAR',
72 'default_value for function default is a SCALAR ref';
74 is eval { $$function_default }, 'getdate()',
75 'default_value for function default is correct';
77 # Test that identity columns do not have 'identity' in the data_type, and do
78 # have is_auto_increment.
79 my $identity_col_info = $schema->resultset('LoaderTest10')
80 ->result_source->column_info('id10');
82 is $identity_col_info->{data_type}, 'int',
83 q{'INT IDENTITY' column has data_type => 'int'};
85 is $identity_col_info->{is_auto_increment}, 1,
86 q{'INT IDENTITY' column has is_auto_increment => 1};