[Bast-commits] r9383 - in DBIx-Class/0.08/trunk: lib/DBIx/Class
t/bind t/sqlahacks
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sat May 15 16:04:59 GMT 2010
Author: ribasushi
Date: 2010-05-15 17:04:59 +0100 (Sat, 15 May 2010)
New Revision: 9383
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/trunk/t/bind/order_by.t
DBIx-Class/0.08/trunk/t/sqlahacks/order_by_func.t
Log:
Revert erroneous commit (belongs in a branch)
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2010-05-15 15:50:57 UTC (rev 9382)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2010-05-15 16:04:59 UTC (rev 9383)
@@ -485,8 +485,6 @@
croak "Malformed select argument - too many keys in hash: " . join (',', keys %$fields );
}
- $func =~ s/^\-+//; # strip leading dash, at some point the dash itself should become mandatory
-
if (lc ($func) eq 'distinct' && ref $args eq 'ARRAY' && @$args > 1) {
croak (
'The select => { distinct => ... } syntax is not supported for multiple columns.'
@@ -577,23 +575,6 @@
]);
}
-sub _order_by_chunks {
- my ($self, $arg) = @_;
- if ( # non-empty hash with neither an -asc or a -desc
- ref $arg eq 'HASH'
- &&
- keys %$arg
- &&
- ! exists $arg->{-desc}
- &&
- ! exists $arg->{-asc}
- ) {
- return $self->_recurse_fields ($arg);
- }
-
- return $self->SUPER::_order_by_chunks ($arg);
-}
-
sub _table {
my ($self, $from) = @_;
if (ref $from eq 'ARRAY') {
Modified: DBIx-Class/0.08/trunk/t/bind/order_by.t
===================================================================
--- DBIx-Class/0.08/trunk/t/bind/order_by.t 2010-05-15 15:50:57 UTC (rev 9382)
+++ DBIx-Class/0.08/trunk/t/bind/order_by.t 2010-05-15 16:04:59 UTC (rev 9383)
@@ -103,3 +103,4 @@
plan( tests => scalar @tests * 2 );
test_order($_) for @tests;
+
Modified: DBIx-Class/0.08/trunk/t/sqlahacks/order_by_func.t
===================================================================
--- DBIx-Class/0.08/trunk/t/sqlahacks/order_by_func.t 2010-05-15 15:50:57 UTC (rev 9382)
+++ DBIx-Class/0.08/trunk/t/sqlahacks/order_by_func.t 2010-05-15 16:04:59 UTC (rev 9383)
@@ -7,45 +7,29 @@
use DBIC::SqlMakerTest;
my $schema = DBICTest->init_schema();
-$schema->storage->sql_maker->quote_char ('"');
-$schema->storage->sql_maker->name_sep ('.');
my $rs = $schema->resultset('CD')->search({}, {
'join' => 'tracks',
- order_by => [
- { -length => 'me.title' },
- {
+ order_by => {
-desc => {
- count => 'tracks.trackid',
+ count => 'tracks.track_id',
},
- },
- ],
+ },
distinct => 1,
rows => 2,
- page => 2,
+ page => 1,
});
+my $match = q{
+ SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me
+ GROUP BY me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
+ ORDER BY COUNT(tracks.trackid) DESC
+};
-is_same_sql_bind(
- $rs->as_query,
- '(
- SELECT "me"."cdid", "me"."artist", "me"."title", "me"."year", "me"."genreid", "me"."single_track"
- FROM cd "me"
- LEFT JOIN "track" "tracks" ON "tracks"."cd" = "me"."cdid"
- GROUP BY "me"."cdid", "me"."artist", "me"."title", "me"."year", "me"."genreid", "me"."single_track"
- ORDER BY
- LENGTH( "me"."title" ),
- COUNT( "tracks"."trackid" ) DESC
- LIMIT 2 OFFSET 2
- )',
- [],
- 'order by with func query',
-);
+TODO: {
+ todo_skip 'order_by using function', 2;
+ is_same_sql($rs->as_query, $match, 'order by with func query');
-ok($rs->count_rs->next == 2, 'amount of rows return in order by func query');
-is_deeply (
- [ $rs->get_column ('me.title')->all ],
- [ "Caterwaulin' Blues", "Come Be Depressed With Us" ],
- 'Correctly ordered stuff by title-length',
-);
+ ok($rs->count == 2, 'amount of rows return in order by func query');
+}
done_testing;
More information about the Bast-commits
mailing list