Hello,
when using subqueries in the 'from' part of a query, sometimes the list of
@bind parameters is not maintained correct. As a simple testcase please find a
primitive subselect enclosed that just does a count with a correlated subquery.
<snip>
# a simple counting subquery
my $subquery =
$schema->resultset('PersonRole')
->search( { role_id => 'admin' } ) # 1st bind param
->count_rs
->as_query;
my @people =
$schema->resultset('Person')
->search(
{
'me.person_id' => 42, # 2nd bind param
},
{
select => [ $subquery ],
# whatever you join here, @bind gets confused
join => 'person_regions'
})
->all;
<snap>
if the 'join' attribute in the main query is left off, the SQL is fired as
expected:
SELECT (SELECT COUNT( * ) FROM person_role me WHERE ( role_id = $1 )) FROM
person me WHERE ( me.person_id = $2 )
DETAIL: parameters: $1 = 'admin', $2 = '42'
however, if the join is present:
DBIx::Class::ResultSet::all(): Cannot bind unknown placeholder 3 (3) at
/Library/Perl/5.10.0/DBIx/Class/Storage/DBI.pm line 1475.
I am using:
- DBIx::Class 0.08123
- SQL::Abstract 1.67
- PostgreSQL 8.4 as the database
PS: I hope it was an intention to use subqueries this way in the 'from' part of
queries...
Regards,
Wolfgang Kinkeldei
--
' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:[email protected] -->
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]