X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F746mssql.t;h=f120c128d18a53675f41280a5500bd454d325e54;hb=d867eedaa703200d7f0bc329836e99b6bd22bc39;hp=4cd1c6ad224e2a2a1c3194f2a009312afe5a23a6;hpb=1f4263ebe497f0a4a7dbde8850a8d1736946740d;p=dbsrgits%2FDBIx-Class.git diff --git a/t/746mssql.t b/t/746mssql.t index 4cd1c6a..f120c12 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -12,8 +12,6 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 39; - DBICTest::Schema->load_classes('ArtistGUID'); my $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -158,13 +156,14 @@ lives_ok { $row = $rs->create({ amount => 100 }); } 'inserted a money value'; -is $rs->find($row->id)->amount, '100.00', 'money value round-trip'; +cmp_ok $rs->find($row->id)->amount, '==', 100, 'money value round-trip'; lives_ok { $row->update({ amount => 200 }); } 'updated a money value'; -is $rs->find($row->id)->amount, '200.00', 'updated money value round-trip'; +cmp_ok $rs->find($row->id)->amount, '==', 200, + 'updated money value round-trip'; lives_ok { $row->update({ amount => undef }); @@ -194,6 +193,8 @@ SQL }); lives_ok ( sub { + # start a new connection, make sure rebless works + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); $schema->populate ('Owners', [ [qw/id name /], [qw/1 wiggle/], @@ -214,7 +215,22 @@ lives_ok ( sub { ]); }, 'populate with PKs supplied ok' ); +lives_ok (sub { + # start a new connection, make sure rebless works + # test an insert with a supplied identity, followed by one without + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); + for (1..2) { + my $id = $_ * 20 ; + $schema->resultset ('Owners')->create ({ id => $id, name => "troglodoogle $id" }); + $schema->resultset ('Owners')->create ({ name => "troglodoogle " . ($id + 1) }); + } +}, 'create with/without PKs ok' ); + +is ($schema->resultset ('Owners')->count, 19, 'owner rows really in db' ); + lives_ok ( sub { + # start a new connection, make sure rebless works + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); $schema->populate ('BooksInLibrary', [ [qw/source owner title /], [qw/Library 1 secrets0/], @@ -260,7 +276,7 @@ $schema->storage->_sql_maker->{name_sep} = '.'; is ($owners->page(3)->count, 2, 'has-many prefetch returns correct count'); is ($owners->page(3)->count_rs->next, 2, 'has-many prefetch returns correct count_rs'); - # make sure count does not become overly complex FIXME + # make sure count does not become overly complex is_same_sql_bind ( $owners->page(3)->count_rs->as_query, '( @@ -300,7 +316,7 @@ $schema->storage->_sql_maker->{name_sep} = '.'; is ($books->page(2)->count, 1, 'Prefetched grouped search returns correct count'); is ($books->page(2)->count_rs->next, 1, 'Prefetched grouped search returns correct count_rs'); - # make sure count does not become overly complex FIXME + # make sure count does not become overly complex (FIXME - the distinct-induced group_by is incorrect) is_same_sql_bind ( $books->page(2)->count_rs->as_query, '( @@ -310,7 +326,7 @@ $schema->storage->_sql_maker->{name_sep} = '.'; FROM [books] [me] JOIN [owners] [owner] ON [owner].[id] = [me].[owner] WHERE ( ( ( [owner].[name] = ? OR [owner].[name] = ? ) AND [source] = ? ) ) - GROUP BY [me].[id], [me].[source], [me].[owner], [me].[title], [me].[price], [owner].[id], [owner].[name] + GROUP BY [me].[id], [me].[source], [me].[owner], [me].[title], [me].[price] ORDER BY [me].[id] DESC ) [count_subq] )', @@ -321,9 +337,10 @@ $schema->storage->_sql_maker->{name_sep} = '.'; ], ); } - } +done_testing; + # clean up our mess END { if (my $dbh = eval { $schema->storage->_dbh }) {