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},
$attrs->{where},$attrs);
}
my $attrs = $self->_resolved_attrs_copy;
+ $attrs->{_virtual_order_by} = $self->_gen_virtual_order;
+
if ($where) {
if (defined $attrs->{where}) {
$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 if such a condition is detected
+
+sub _gen_virtual_order {
+ my $self = shift;
+ my $attrs = $self->_resolved_attrs_copy;
+
+ if ($attrs->{rows} or $attrs->{offset} ) {
+
+# This check requires ensure_connected, so probably cheaper to just calculate all the time
+
+# my $sm = $self->result_source->storage->_sql_maker;
+#
+# if ($sm->_default_limit_syntax eq 'Top' and not @{$sm->_resolve_order ($attrs->{order_by}) }) {
+
+ return [ $self->result_source->primary_columns ];
+
+# }
+ }
+
+ return undef;
+}
+
# _is_unique_query
#
# Try to determine if the specified query is guaranteed to be unique, based on