From: Peter Rabbitson Date: Fri, 4 Dec 2009 11:24:13 +0000 (+0000) Subject: Tests for bindvar propagation and Changes X-Git-Tag: v0.08116~103^2~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9010bab88f064790345777f65a9dd65e2712e751;hp=6bc666a5ec74e09c1aaf7053753637f9830a2cc9;p=dbsrgits%2FDBIx-Class.git Tests for bindvar propagation and Changes --- diff --git a/Changes b/Changes index 11d3c9c..8cf2fbe 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for DBIx::Class + - Real limit/offset support for MSSQL server (via Row_Number) - Fix distinct => 1 with non-selecting order_by (the columns in order_by also need to be aded to the resulting group_by) - Do not attempt to deploy FK constraints pointing to a View diff --git a/t/746mssql.t b/t/746mssql.t index 8ee8a23..e883c22 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -275,15 +275,22 @@ $schema->storage->_sql_maker->{name_sep} = '.'; # try a ->has_many direction my $owners = $schema->resultset ('Owners')->search ( { - 'books.id' => { '!=', undef } + 'books.id' => { '!=', undef }, + 'me.name' => { '!=', 'somebogusstring' }, }, { prefetch => 'books', - order_by => 'name', + order_by => { -asc => \['name + ?', [ test => 'xxx' ]] }, # test bindvar propagation rows => 3, # 8 results total }, ); + my ($sql, @bind) = @${$owners->page(3)->as_query}; + is_deeply ( + \@bind, + [ ([ 'me.name' => 'somebogusstring' ], [ test => 'xxx' ]) x 2 ], # double because of the prefetch subq + ); + is ($owners->page(1)->all, 3, 'has_many prefetch returns correct number of rows'); is ($owners->page(1)->count, 3, 'has-many prefetch returns correct count'); @@ -299,6 +306,7 @@ $schema->storage->_sql_maker->{name_sep} = '.'; }, { distinct => 1, + having => \['1 = ?', [ test => 1 ] ], #test having propagation prefetch => 'owner', rows => 2, # 3 results total order_by => { -desc => 'owner' }, @@ -307,6 +315,16 @@ $schema->storage->_sql_maker->{name_sep} = '.'; }, ); + ($sql, @bind) = @${$books->page(3)->as_query}; + is_deeply ( + \@bind, + [ + # inner + [ 'owner.name' => 'wiggle' ], [ 'owner.name' => 'woggle' ], [ source => 'Library' ], [ test => '1' ], + # outer + [ 'owner.name' => 'wiggle' ], [ 'owner.name' => 'woggle' ], [ source => 'Library' ], + ], + ); is ($books->page(1)->all, 2, 'Prefetched grouped search returns correct number of rows'); is ($books->page(1)->count, 2, 'Prefetched grouped search returns correct count');