# 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 $prefix = $alias . ($source->schema->storage->_sql_maker_opts->{name_sep} || '.');
+ $attrs->{_virtual_order_by} = [
+ map { $prefix . $_ } ($source->primary_columns)
+ ];
$attrs->{collapse} ||= {};
if ( my $prefetch = delete $attrs->{prefetch} ) {