X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F73oracle_hq.t;h=0595edf532d4e53964745d6a8151009a5d9f5744;hb=bedbc8111dbbb98f89a36c3cf4e2f6903a4b01be;hp=de4673b7af62fc4bb34486a43a6fecbd6d783c08;hpb=8d6b1478d8fa6f7c76e313ee72a72d5eb4c24d03;p=dbsrgits%2FDBIx-Class.git diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index de4673b..0595edf 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -5,12 +5,6 @@ use Test::Exception; use Test::More; use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); -use DBICTest::RunMode; -use DBIC::SqlMakerTest; - -use DBIx::Class::SQLMaker::LimitDialects; -my $ROWS = DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype, -my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype, $ENV{NLS_SORT} = "BINARY"; $ENV{NLS_COMP} = "BINARY"; @@ -114,35 +108,12 @@ do_creates($dbh); connect_by => { parentid => { -prior => { -ident => '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 parentid = PRIOR artistid - )', - [ [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'] ], - ); is_deeply ( [ $rs->get_column ('name')->all ], [ qw/root child1 grandchild greatgrandchild child2/ ], 'got artist tree', ); - is_same_sql_bind ( - $rs->count_rs->as_query, - '( - SELECT COUNT( * ) - FROM artist me - START WITH name = ? - CONNECT BY parentid = PRIOR artistid - )', - [ [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'] ], - ); - is( $rs->count, 5, 'Connect By count ok' ); } @@ -158,19 +129,6 @@ do_creates($dbh); order_siblings_by => { -desc => 'name' }, }); - 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 parentid = PRIOR artistid - ORDER SIBLINGS BY name DESC - )', - [ [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'] ], - ); - is_deeply ( [ $rs->get_column ('name')->all ], [ qw/root child2 child1 grandchild greatgrandchild/ ], @@ -185,19 +143,6 @@ do_creates($dbh); connect_by => { parentid => { -prior => { -ident => 'artistid' } } }, }); - is_same_sql_bind ( - $rs->as_query, - '( - SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid - FROM artist me - WHERE ( parentid IS NULL ) - START WITH name = ? - CONNECT BY parentid = PRIOR artistid - )', - [ [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'] ], - ); - is_deeply( [ $rs->get_column('name')->all ], [ 'root' ], @@ -220,48 +165,12 @@ do_creates($dbh); } ); - is_same_sql_bind ( - $rs->as_query, - '( - SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid - FROM artist me - LEFT JOIN cd cds ON cds.artist = me.artistid - WHERE ( cds.title LIKE ? ) - START WITH me.name = ? - CONNECT BY parentid = PRIOR artistid - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'cds.title', 'sqlt_size' => 100 } - => '%cd'], - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'me.name', 'sqlt_size' => 100 } - => 'root'], - ], - ); - is_deeply( [ $rs->get_column('name')->all ], [ 'grandchild' ], 'Connect By with a join result name ok' ); - is_same_sql_bind ( - $rs->count_rs->as_query, - '( - SELECT COUNT( * ) - FROM artist me - LEFT JOIN cd cds ON cds.artist = me.artistid - WHERE ( cds.title LIKE ? ) - START WITH me.name = ? - CONNECT BY parentid = PRIOR artistid - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'cds.title', 'sqlt_size' => 100 } - => '%cd'], - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'me.name', 'sqlt_size' => 100 } - => 'root'], - ], - ); - is( $rs->count, 1, 'Connect By with a join; count ok' ); } @@ -273,22 +182,6 @@ do_creates($dbh); order_by => { -asc => [ 'LEVEL', 'name' ] }, }); - 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 parentid = PRIOR artistid - ORDER BY LEVEL ASC, name ASC - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'], - ], - ); - - # Don't use "$rs->get_column ('name')->all" they build a query arround the $rs. # If $rs has a order by, the order by is in the subquery and this doesn't work with Oracle 8i. # TODO: write extra test and fix order by handling on Oracle 8i @@ -322,53 +215,12 @@ do_creates($dbh); rows => 2, }); - is_same_sql_bind ( - $rs->as_query, - '( - SELECT artistid, name, rank, charfield, parentid - FROM ( - SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid - FROM artist me - START WITH name = ? - CONNECT BY parentid = PRIOR artistid - ORDER BY name ASC, artistid DESC - ) me - WHERE ROWNUM <= ? - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'], [ $ROWS => 2 ], - ], - ); - is_deeply ( [ $rs->get_column ('name')->all ], [qw/child1 child2/], 'LIMIT a Connect By query - correct names' ); - is_same_sql_bind ( - $rs->count_rs->as_query, - '( - SELECT COUNT( * ) - FROM ( - SELECT artistid - FROM ( - SELECT me.artistid - FROM artist me - START WITH name = ? - CONNECT BY parentid = PRIOR artistid - ) me - WHERE ROWNUM <= ? - ) me - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'], - [ $ROWS => 2 ], - ], - ); - is( $rs->count, 2, 'Connect By; LIMIT count ok' ); } @@ -384,27 +236,6 @@ do_creates($dbh); having => \[ 'count(rank) < ?', [ cnt => 2 ] ], }); - is_same_sql_bind ( - $rs->as_query, - '( - SELECT COUNT(rank) + ? - FROM artist me - START WITH name = ? - CONNECT BY parentid = PRIOR artistid - GROUP BY( rank + ? ) HAVING count(rank) < ? - )', - [ - [ { dbic_colname => '__cbind' } - => 3 ], - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'root'], - [ { dbic_colname => '__gbind' } - => 1 ], - [ { dbic_colname => 'cnt' } - => 2 ], - ], - ); - is_deeply ( [ $rs->get_column ('cnt')->all ], [4, 4], @@ -437,19 +268,6 @@ do_creates($dbh); connect_by_nocycle => { parentid => { -prior => { -ident => 'artistid' } } }, }); - is_same_sql_bind ( - $rs->as_query, - '( - SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid, CONNECT_BY_ISCYCLE - FROM artist me - START WITH name = ? - CONNECT BY NOCYCLE parentid = PRIOR artistid - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'cycle-root'], - ], - ); is_deeply ( [ $rs->get_column ('name')->all ], [ qw/cycle-root cycle-child1 cycle-grandchild cycle-child2/ ], @@ -461,20 +279,6 @@ do_creates($dbh); 'got artist tree with nocycle (CONNECT_BY_ISCYCLE)', ); - is_same_sql_bind ( - $rs->count_rs->as_query, - '( - SELECT COUNT( * ) - FROM artist me - START WITH name = ? - CONNECT BY NOCYCLE parentid = PRIOR artistid - )', - [ - [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 } - => 'cycle-root'], - ], - ); - is( $rs->count, 4, 'Connect By Nocycle count ok' ); } }