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 ts DATETIME DEFAULT getdate()
28 drop => [ "[${vendor}_loader_test1.dot]", "${vendor}_loader_test2" ],
31 my ($schema, $monikers, $classes) = @_;
33 # Test that the table above (with '.' in name) gets loaded correctly.
34 my $vendor_titlecased = "\u\L$vendor";
37 $schema->resultset("${vendor_titlecased}LoaderTest1Dot") }),
38 'got a resultset for table with dot in name');
40 ok((my $from = eval { $rs->result_source->from }),
41 'got an $rsrc->from for table with dot in name');
43 is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
45 is eval { $$from }, "[${vendor}_loader_test1.dot]",
46 '->table with dot in name has correct name';
48 # Test that column defaults are set correctly
50 $schema->resultset("${vendor_titlecased}LoaderTest2") }),
51 'got a resultset for table with column with default value');
53 my $rsrc = $rs->result_source;
55 is eval { $rsrc->column_info('dat')->{default_value} }, 'foo',
56 'correct default_value for column with literal default';
58 ok((my $function_default =
59 eval { $rsrc->column_info('ts')->{default_value} }),
60 'got default_value for column with function default');
62 is ref($function_default), 'SCALAR',
63 'default_value for function default is a SCALAR ref';
65 is eval { $$function_default }, 'getdate()',
66 'default_value for function default is correct';
68 # Test that identity columns do not have 'identity' in the data_type, and do
69 # have is_auto_increment.
70 my $identity_col_info = $schema->resultset('LoaderTest10')
71 ->result_source->column_info('id10');
73 is $identity_col_info->{data_type}, 'int',
74 q{'INT IDENTITY' column has data_type => 'int'};
76 is $identity_col_info->{is_auto_increment}, 1,
77 q{'INT IDENTITY' column has is_auto_increment => 1};