my ($self) = @_;
my $attrs = $self->_resolved_attrs_copy;
- $attrs->{_virtual_order_by} = $self->_gen_virtual_order;
return $self->{cursor}
||= $self->result_source->storage->select($attrs->{from}, $attrs->{select},
}
my $attrs = $self->_resolved_attrs_copy;
- $attrs->{_virtual_order_by} = $self->_gen_virtual_order;
if ($where) {
if (defined $attrs->{where}) {
return (@data ? ($self->_construct_object(@data))[0] : undef);
}
-# _gen_virtual_order
-#
-# This is a horrble hack, but seems like the best we can do at this point
-# Some limit emulations (Top) require an ordered resultset in order to
-# function at all. So supply a PK order to be used if necessary
-
-sub _gen_virtual_order {
- return [ shift->result_source->primary_columns ];
-}
# _is_unique_query
#
$attrs->{order_by} = [];
}
+ # If the order_by is otherwise empty - we will use this for TOP limit
+ # emulation and the like.
+ # Although this is needed only if the order_by is not defined, it is
+ # actually cheaper to just populate this rather than properly examining
+ # order_by (stuf like [ {} ] and the like)
+ $attrs->{_virtual_order_by} = [ $self->result_source->primary_columns ];
+
+
my $collapse = $attrs->{collapse} || {};
if ( my $prefetch = delete $attrs->{prefetch} ) {
$prefetch = $self->_merge_attr( {}, $prefetch );
sub _select_args {
my ($self, $ident, $select, $condition, $attrs) = @_;
- my $order = $attrs->{order_by};
my $for = delete $attrs->{for};
my $sql_maker = $self->sql_maker;
$sql_maker->{for} = $for;
- my @in_order_attrs = qw/group_by having _virtual_order_by/;
- if (List::Util::first { exists $attrs->{$_} } (@in_order_attrs) ) {
- $order = {
- ($order
- ? (order_by => $order)
- : ()
- ),
- ( map { $_ => $attrs->{$_} } (@in_order_attrs) )
- };
- }
+ my $order = { map
+ { $attrs->{$_} ? ( $_ => $attrs->{$_} ) : () }
+ (qw/order_by group_by having _virtual_order_by/ )
+ };
+
my $bind_attrs = {}; ## Future support
my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order);
if ($attrs->{software_limit} ||