[Dbix-class] order_by interfering with has_many fetch

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Nov 16 09:08:13 GMT 2015


On 11/16/2015 06:20 AM, Darin McBride wrote:
> On Sunday November 15 2015 7:09:05 PM Darin McBride wrote:
> So, the column is:
>
> __PACKAGE__->add_columns(
>      name                    => { data_type => 'varchar', size => 30,
> is_nullable => 0 },
>
> So, explicitly not nullable.
>
> I've added this code as the next executable line after all the columns:
>
> __PACKAGE__->add_unique_constraint(name => ['name']);
>
> And now my search (which has grown since last time - I'm now prefetching
> sitterauths, too, since I'm going to need a field from there for each empire
> returned) looks like this:
>
>          $planet_rs =
>              Lacuna->db->resultset('Map::Body')->
>              search(
>                     {
>                         'sitterauths.sitter_id' => $real_empire->id,
>                         'me.class' => { '!=' =>
> 'Lacuna::DB::Result::Map::Body::Planet::Station' },
>                     },
>                     {
>                         join => { empire => 'sitterauths' },
>                         prefetch => { 'empire', 'sitterauths' },
>                         order_by => ['me.name'],
>                     });
>

Please use the resultset exactly as defined above, execute the following 
and get me its result:


use Devel::Dwarn;
$Data::Dumper::Maxdepth = 3;
Dwarn [
  $planet_rs->result_source
             ->schema
              ->storage
               ->_extract_colinfo_of_stable_main_source_order_by_portion(
                 $planet_rs->_resolved_attrs
               )
]




More information about the DBIx-Class mailing list