[Dbix-class] order_by interfering with has_many fetch
Darin McBride
darin.mcbride at shaw.ca
Mon Nov 16 18:16:27 GMT 2015
On Monday November 16 2015 10:08:13 AM Peter Rabbitson wrote:
> 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
> )
> ]
[]
If I put me.id back in, then it gives me a hash of the two keys and other
interesting things, but without me.id, so exactly as defined above, it's empty.
Just double checking that I still have the unique constraint defined, and I do.
(It's not defined as a unique constraint in the db though, I was going to add
that later, since I suspect we'll get some minor speed improvement from it.)
Thanks,
More information about the DBIx-Class
mailing list