[Bast-commits] r9302 - in
DBIx-Class/0.08/branches/subqueried_limit_fixes/t: .
sqlahacks sqlahacks/limit_dialects
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed May 5 09:12:19 GMT 2010
Author: ribasushi
Date: 2010-05-05 10:12:18 +0100 (Wed, 05 May 2010)
New Revision: 9302
Added:
DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/limit_dialects/rownum.t
DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/oraclejoin.t
Removed:
DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t
Log:
Split and fix oracle tests
Deleted: DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t
===================================================================
--- DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t 2010-05-05 09:11:32 UTC (rev 9301)
+++ DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t 2010-05-05 09:12:18 UTC (rev 9302)
@@ -1,89 +0,0 @@
-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 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) = @_;
-my ($sql, @bind) = $sa->select(
- [
- { me => "cd" },
- [
- { "-join_type" => "LEFT", artist => "artist" },
- { "artist.artistid" => "me.artist" },
- ],
- ],
- [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
- undef,
- undef
-);
-is_same_sql_bind(
- $sql, \@bind,
- 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
- 'WhereJoins search with empty where clause'
-);
-
-($sql, @bind) = $sa->select(
- [
- { me => "cd" },
- [
- { "-join_type" => "", artist => "artist" },
- { "artist.artistid" => "me.artist" },
- ],
- ],
- [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
- { 'artist.artistid' => 3 },
- undef
-);
-is_same_sql_bind(
- $sql, \@bind,
- 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist ) AND ( artist.artistid = ? ) ) )', [3],
- 'WhereJoins search with where clause'
-);
-
-($sql, @bind) = $sa->select(
- [
- { me => "cd" },
- [
- { "-join_type" => "LEFT", artist => "artist" },
- { "artist.artistid" => "me.artist" },
- ],
- ],
- [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
- [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
- undef
-);
-is_same_sql_bind(
- $sql, \@bind,
- 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid(+) = me.artist ) AND ( ( ( artist.artistid = ? ) OR ( me.cdid = ? ) ) ) ) )', [3, 5],
- 'WhereJoins search with or in where clause'
-);
-
-
Copied: DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/limit_dialects/rownum.t (from rev 9283, DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t)
===================================================================
--- DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/limit_dialects/rownum.t (rev 0)
+++ DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/limit_dialects/rownum.t 2010-05-05 09:12:18 UTC (rev 9302)
@@ -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;
Copied: DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/oraclejoin.t (from rev 9283, DBIx-Class/0.08/branches/subqueried_limit_fixes/t/41orrible.t)
===================================================================
--- DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/oraclejoin.t (rev 0)
+++ DBIx-Class/0.08/branches/subqueried_limit_fixes/t/sqlahacks/oraclejoin.t 2010-05-05 09:12:18 UTC (rev 9302)
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib qw(t/lib);
+use DBIx::Class::SQLAHacks::OracleJoins;
+use DBICTest;
+use DBIC::SqlMakerTest;
+
+my $sa = new DBIx::Class::SQLAHacks::OracleJoins;
+
+# search with undefined or empty $cond
+
+# my ($self, $table, $fields, $where, $order, @rest) = @_;
+my ($sql, @bind) = $sa->select(
+ [
+ { me => "cd" },
+ [
+ { "-join_type" => "LEFT", artist => "artist" },
+ { "artist.artistid" => "me.artist" },
+ ],
+ ],
+ [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
+ undef,
+ undef
+);
+is_same_sql_bind(
+ $sql, \@bind,
+ 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
+ 'WhereJoins search with empty where clause'
+);
+
+($sql, @bind) = $sa->select(
+ [
+ { me => "cd" },
+ [
+ { "-join_type" => "", artist => "artist" },
+ { "artist.artistid" => "me.artist" },
+ ],
+ ],
+ [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
+ { 'artist.artistid' => 3 },
+ undef
+);
+is_same_sql_bind(
+ $sql, \@bind,
+ 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist ) AND ( artist.artistid = ? ) ) )', [3],
+ 'WhereJoins search with where clause'
+);
+
+($sql, @bind) = $sa->select(
+ [
+ { me => "cd" },
+ [
+ { "-join_type" => "LEFT", artist => "artist" },
+ { "artist.artistid" => "me.artist" },
+ ],
+ ],
+ [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
+ [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
+ undef
+);
+is_same_sql_bind(
+ $sql, \@bind,
+ 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid(+) = me.artist ) AND ( ( ( artist.artistid = ? ) OR ( me.cdid = ? ) ) ) ) )', [3, 5],
+ 'WhereJoins search with or in where clause'
+);
+
+done_testing;
+
More information about the Bast-commits
mailing list