X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsqlmaker%2Flimit_dialects%2Fgeneric_subq.t;h=5ed89c0ff116efd8d41e5fcdd3012628ea7ce781;hb=7d5810cd5d389cee98fecaf5d27ac7ed2f27dce4;hp=2d483e9f3799e605bf85c32a5177de394e5cb881;hpb=90ed89cbd9951c4eeccb227b586b200eb34574d2;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/sqlmaker/limit_dialects/generic_subq.t b/t/sqlmaker/limit_dialects/generic_subq.t index 2d483e9..5ed89c0 100644 --- a/t/sqlmaker/limit_dialects/generic_subq.t +++ b/t/sqlmaker/limit_dialects/generic_subq.t @@ -155,4 +155,40 @@ is_deeply ( ); } +# this is a nonsensical order_by, we are just making sure the bind-transport is correct +# (not that it'll be useful anywhere in the near future) +my $attr = {}; +my $rs_selectas_rel = $schema->resultset('BooksInLibrary')->search(undef, { + columns => 'me.id', + offset => 3, + rows => 4, + '+columns' => { bar => \['? * ?', [ $attr => 11 ], [ $attr => 12 ]], baz => \[ '?', [ $attr => 13 ]] }, + order_by => [ 'id', \['? / ?', [ $attr => 1 ], [ $attr => 2 ]], \[ '?', [ $attr => 3 ]] ], + having => \[ '?', [ $attr => 21 ] ], +}); + +is_same_sql_bind( + $rs_selectas_rel->as_query, + '( + SELECT "me"."id", "bar", "baz" + FROM ( + SELECT "me"."id", ? * ? AS "bar", ? AS "baz" + FROM "books" "me" + WHERE ( "source" = ? ) + HAVING ? + ) "me" + WHERE ( SELECT COUNT(*) FROM "books" "rownum__emulation" WHERE "rownum__emulation"."id" < "me"."id" ) BETWEEN ? AND ? + ORDER BY "id", ? / ?, ? + )', + [ + [ $attr => 11 ], [ $attr => 12 ], [ $attr => 13 ], + [ { sqlt_datatype => 'varchar', sqlt_size => 100, dbic_colname => 'source' } => 'Library' ], + [ $attr => 21 ], + [ {%$OFFSET} => 3 ], + [ {%$TOTAL} => 6 ], + [ $attr => 1 ], [ $attr => 2 ], [ $attr => 3 ], + ], + 'Pagination with sub-query in ORDER BY works' +); + done_testing;