<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div>Hello everbody,<br><br></div>is it possible to use a resultset as subquery in the FROM clause and prefetch its results in a way, that it is available as an accessor in the final resultset?<br><br></div>In detail I would like to do a query like that:<br><br></div>select me.*, properties.me_id, properties.value<br>from table_me me join ( select id, property from complex_subselect where condition ) properties</div>on <a href="http://me.id">me.id</a> = <a href="http://properties.id">properties.id</a><br><br></div>... and the "properties" should be collapsed to the me-Table.<br><br></div>I would like to use DBIx::Class::ResultClass::HashRefInflator, but I think this is based on defining a "prefetch" and again this needs to find accessors in the underlying table_me resultset definition.<br><br></div><div>At the beginning working around this problem seemed kind of trivial to me, but now I'm
struggling. I thought, I could simply use a sub query in the
from-attribute when searching the resultset and adding "+columns" and
setting "collapse" to a true value. But this way, I am ending up with only a
single property column.<br><br></div>What I want my final result hash to look like is...<br></div><div><br>[<br></div> {<br></div><div> <a href="http://me.id">me.id</a> => 1,<br></div> me.hello => "world",<br></div> me.some => "thing",<br></div><div> # ... more fields<br><br></div> properties => [<br></div> { me_id => 1, value => "something, that I don't get by simply joining tables" },<br> { me_id => 1, value => "the next item in a really long lis" },<br></div> # ... more properties<br><div> ]<br><div><div><div><div> },<br> {<br></div><div> # .... next result object<br></div><div> }<br><div><div>]<br><br></div><div>Is it possible to do that in a single database request (with DBIx::Class::ResultClass::HashRefInflator)?<br></div><div><br>Thanks in advance : )<br></div><div>Thilo<br></div></div></div></div></div></div></div></div>