Closed joe-meyer closed 9 years ago
For what it's worth this seems to be an issue with the buildCompositeInCondition
function in teh QueryBuilder. Swapping it out with this seems to work (although might be able to be prettied up a bit):
protected function buildCompositeInCondition($operator, $columns, $values, &$params)
{
$vss = [];
foreach ($values as $value) {
$vs = [];
foreach ($columns as $column) {
if (isset($value[$column])) {
$phName = self::PARAM_PREFIX . count($params);
$params[$phName] = $value[$column];
$vs[] = $phName;
} else {
$vs[] = 'NULL';
}
}
$vss[] = $vs;
}
foreach ($columns as $i => $column) {
if (strpos($column, '(') === false) {
$columns[$i] = $this->db->quoteColumnName($column);
}
}
$condition = '';
foreach ($vss AS $vs) {
$condition .= '(';
for($i = 0; $i < count($vs); $i++) {
$condition .= '(' . $columns[$i] . ' ' . $operator . ' (' . $vs[$i] . ')) AND ';
};
$condition = substr($condition, 0, -4);
$condition .= ') OR ';
}
$condition = substr($condition, 0, -3);
return $condition;
}
As a reference, here's PostgreSQL docs about row constructors.
It is not supported in SQLite and MySQL afaik.
I will provide a PR with a unit test with @EC-Joe's change.
@nineinchnick is this still something you're planning on looking at? If not is this something that could be put on a road map somewhere? If more information needs to be provided please let me know so that I can help the issue move forward. Thanks
Yeah, sorry for the delay, I'll have some free time today to pick it up.
Updated the PR.
Great work. Thanks @nineinchnick!
I've found that when trying to do a
joinWith
on ahasMany
relation that tries to join on more than 1 column, I receive malformed SQL which results in a failure. Sample code of what producdes the error can be seen in thefindPartCommentsSummary
function belowCall Stack: