X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F73oracle.t;h=f1c1ca0b8fcee70ac96c995c2db5997c954be1f5;hb=2ba03b1627e18f422a84948277b72fd1c80da3a0;hp=a8ca4015a721a195ec53eb5c429a5ec728bf82b1;hpb=25ca709b095f6f33043eaf056b34720f2334a04d;p=dbsrgits%2FDBIx-Class.git diff --git a/t/73oracle.t b/t/73oracle.t index a8ca401..f1c1ca0 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -586,27 +586,66 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) { # after count_subq, # I will fix this later... # + # is_same_sql_bind ( + # $rs->count_rs->as_query, + # '( + # SELECT COUNT( * ) FROM ( + # SELECT * FROM ( + # SELECT A.*, ROWNUM r FROM ( + # SELECT + # me.artistid AS col1 + # FROM artist me + # START WITH name = ? + # CONNECT BY artistid = PRIOR( parentid ) + # ) A + # WHERE ROWNUM < 3 + # ) B + # WHERE r >= 1 + # ) count_subq + # )', + # [ [ name => 'greatgrandchild' ] ], + # ); + # + # is( $rs->count, 2, 'Connect By; LIMIT count ok' ); + } + + # select the whole tree with nocylce + { + my $rs = $schema->resultset('Artist')->search({}, { + nocycle => 1, + start_with => { name => 'root' }, + connect_by => { parentid => { -prior => \ 'artistid' } }, + }); + + is_same_sql_bind ( + $rs->as_query, + '( + SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid + FROM artist me + START WITH name = ? + CONNECT BY NOCYCLE parentid = PRIOR( artistid ) + )', + [ [ name => 'root'] ], + ); + is_deeply ( + [ $rs->get_column ('name')->all ], + [ qw/root child1 grandchild greatgrandchild child2/ ], + 'got artist tree with nocycle', + ); + + is_same_sql_bind ( $rs->count_rs->as_query, - '( - SELECT COUNT( * ) FROM ( - SELECT * FROM ( - SELECT A.*, ROWNUM r FROM ( - SELECT - me.artistid AS col1 - FROM artist me - START WITH name = ? - CONNECT BY artistid = PRIOR( parentid ) - ) A - WHERE ROWNUM < 3 - ) B - WHERE r >= 1 - ) count_subq + '( + SELECT COUNT( * ) + FROM artist me + START WITH name = ? + CONNECT BY NOCYCLE parentid = PRIOR( artistid ) )', - [ [ name => 'greatgrandchild' ] ], + [ [ name => 'root'] ], ); - is( $rs->count, 2, 'Connect By; LIMIT count ok' ); + is( $rs->count, 5, 'Connect By Nocycle count ok' ); } }