X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F16mssql_common.t;h=114d9917b6ad44217d27683f801dc936b54f5938;hb=020f3c3ab66a216064907bfcee815f2d77bbb63f;hp=61a9ffeec82599e5b66f5f65737014e880052e4c;hpb=eac5494b870c5acf35b3a3a541a5f6f4a6f57c34;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/16mssql_common.t b/t/16mssql_common.t index 61a9ffe..114d991 100644 --- a/t/16mssql_common.t +++ b/t/16mssql_common.t @@ -57,17 +57,22 @@ my $tester = dbixcsl_common_tests->new( CREATE VIEW mssql_loader_test4 AS SELECT * FROM mssql_loader_test3 }, - # test capitalization of cols in unique constraints + # test capitalization of cols in unique constraints and rels q{ SET QUOTED_IDENTIFIER ON }, q{ SET ANSI_NULLS ON }, q{ - CREATE TABLE [mssql_loader_test5] ( - [id] INT IDENTITY NOT NULL PRIMARY KEY, + CREATE TABLE [MSSQL_Loader_Test5] ( + [Id] INT IDENTITY NOT NULL PRIMARY KEY, [FooCol] INT NOT NULL, [BarCol] INT NOT NULL, UNIQUE ([FooCol], [BarCol]) ) }, + q{ + CREATE TABLE [MSSQL_Loader_Test6] ( + [Five_Id] INT REFERENCES [MSSQL_Loader_Test5] ([Id]) + ) + }, ], pre_drop_ddl => [ 'CREATE TABLE mssql_loader_test3 (id INT IDENTITY NOT NULL PRIMARY KEY)', @@ -77,8 +82,9 @@ my $tester = dbixcsl_common_tests->new( '[mssql_loader_test1.dot]', 'mssql_loader_test3', 'mssql_loader_test5', + 'mssql_loader_test6', ], - count => 9, + count => 11, run => sub { my ($schema, $monikers, $classes) = @_; @@ -99,7 +105,10 @@ my $tester = dbixcsl_common_tests->new( ok ((my $rsrc = $schema->resultset($monikers->{mssql_loader_test5})->result_source), 'got result_source'); - is $rsrc->column_info('foocol')->{data_type}, 'int', + is $rsrc->name, 'mssql_loader_test5', + 'table name is lowercased'; + + is_deeply [ $rsrc->columns ], [qw/id foocol barcol/], 'column names are lowercased'; my %uniqs = $rsrc->unique_constraints; @@ -108,6 +117,13 @@ my $tester = dbixcsl_common_tests->new( is_deeply ((values %uniqs)[0], [qw/foocol barcol/], 'columns in unique constraint lowercased'); + lives_and { + my $five_row = $schema->resultset($monikers->{mssql_loader_test5})->create({ foocol => 1, barcol => 2 }); + my $six_row = $five_row->create_related('mssql_loader_test6s', {}); + + is $six_row->five->id, 1; + } 'relationships for mixed-case tables/columns detected'; + # Test that a bad view (where underlying table is gone) is ignored. my $dbh = $schema->storage->dbh; $dbh->do("DROP TABLE mssql_loader_test3");