From: Peter Rabbitson Date: Wed, 5 May 2010 09:12:18 +0000 (+0000) Subject: Split and fix oracle tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=327368bcbbf179bbf95ee6a1dee701b3020400e8;p=dbsrgits%2FDBIx-Class-Historic.git Split and fix oracle tests --- diff --git a/t/sqlahacks/limit_dialects/rownum.t b/t/sqlahacks/limit_dialects/rownum.t new file mode 100644 index 0000000..85ca3e8 --- /dev/null +++ b/t/sqlahacks/limit_dialects/rownum.t @@ -0,0 +1,35 @@ +use strict; +use warnings; + +use Test::More; + +use lib qw(t/lib); +use DBICTest; +use DBIC::SqlMakerTest; + +my $s = DBICTest->init_schema (no_deploy => 1, ); +$s->storage->sql_maker->limit_dialect ('RowNum'); + +my $rs = $s->resultset ('CD'); + +is_same_sql_bind ( + $rs->search ({}, { rows => 1, offset => 3,columns => [ + { id => 'foo.id' }, + { 'bar.id' => 'bar.id' }, + { bleh => \ 'TO_CHAR (foo.womble, "blah")' }, + ]})->as_query, + '(SELECT id, bar__id, bleh + FROM ( + SELECT id, bar__id, bleh, ROWNUM rownum__index + FROM ( + SELECT foo.id AS id, bar.id AS bar__id, TO_CHAR(foo.womble, "blah") AS bleh + FROM cd me + ) me + ) me + WHERE rownum__index BETWEEN 4 AND 4 + )', + [], + 'Rownum subsel aliasing works correctly' +); + +done_testing; diff --git a/t/41orrible.t b/t/sqlahacks/oraclejoin.t similarity index 80% rename from t/41orrible.t rename to t/sqlahacks/oraclejoin.t index b0117a7..83c8332 100644 --- a/t/41orrible.t +++ b/t/sqlahacks/oraclejoin.t @@ -2,33 +2,14 @@ use strict; use warnings; use Test::More; -use DBIx::Class::SQLAHacks::OracleJoins; use lib qw(t/lib); -use DBICTest; # do not remove even though it is not used +use DBIx::Class::SQLAHacks::OracleJoins; +use DBICTest; use DBIC::SqlMakerTest; -plan tests => 4; - my $sa = new DBIx::Class::SQLAHacks::OracleJoins; -$sa->limit_dialect('RowNum'); - -is($sa->select('rubbish', - [ 'foo.id', 'bar.id', \'TO_CHAR(foo.womble, "blah")' ], - undef, undef, 1, 3), - 'SELECT * FROM -( - SELECT A.*, ROWNUM r FROM - ( - SELECT foo.id AS col1, bar.id AS col2, TO_CHAR(foo.womble, "blah") AS col3 FROM rubbish - ) A - WHERE ROWNUM < 5 -) B -WHERE r >= 4 -', 'Munged stuff to make Oracle not explode'); - -# test WhereJoins # search with undefined or empty $cond # my ($self, $table, $fields, $where, $order, @rest) = @_; @@ -86,4 +67,5 @@ is_same_sql_bind( 'WhereJoins search with or in where clause' ); +done_testing;