X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBIHacks.pm;h=adab1d84968b5c51a3dc9ba851e41d3c3a44b43f;hb=576ea48fa3ff6baaa7d539c36e660a9fc73899e9;hp=ce169170d84cdef6f69b2199111b969f56bd940e;hpb=0844bb396f5702db73a8eea947116475b4d89e9a;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index ce16917..adab1d8 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -630,12 +630,9 @@ sub _group_over_selection { # of the external order and convert them to MIN(X) for ASC or MAX(X) # for DESC, and group_by the root columns. The end result should be # exactly what we expect + # - # FIXME - this code is a joke, will need to be completely rewritten in - # the DQ branch. But I need to push a POC here, otherwise the - # pesky tests won't pass - # wrap any part of the order_by that "responds" to an ordering alias - # into a MIN/MAX + # both populated on the first loop over $o_idx $sql_maker ||= $self->sql_maker; $order_chunks ||= [ map { ref $_ eq 'ARRAY' ? $_ : [ $_ ] } $sql_maker->_order_by_chunks($attrs->{order_by}) @@ -645,7 +642,7 @@ sub _group_over_selection { $new_order_by[$o_idx] = \[ sprintf( '%s( %s )%s', - ($is_desc ? 'MAX' : 'MIN'), + $self->_minmax_operator_for_datatype($chunk_ci->{data_type}, $is_desc), $chunk, ($is_desc ? ' DESC' : ''), ), @@ -673,6 +670,12 @@ sub _group_over_selection { ); } +sub _minmax_operator_for_datatype { + #my ($self, $datatype, $want_max) = @_; + + $_[2] ? 'MAX' : 'MIN'; +} + sub _resolve_ident_sources { my ($self, $ident) = @_;