Permalink
Browse files

Fixing Sqlite tests for eager loading when using identifier quoting

  • Loading branch information...
1 parent ae2127e commit af6ccdb914150dbd3641248d83a95a3f6438641d @lorenzo lorenzo committed Jan 15, 2014
Showing with 11 additions and 5 deletions.
  1. +5 −4 Cake/Database/Dialect/SqliteDialectTrait.php
  2. +6 −1 Cake/Database/Expression/TupleComparison.php
@@ -112,21 +112,22 @@ protected function _transformTupleComparison(TupleComparison $expression, $query
$value = $expression->getValue();
$op = $expression->type();
+ $true = new QueryExpression('1');
if ($value instanceof Query) {
$selected = array_values($value->clause('select'));
foreach ($fields as $i => $field) {
$value->andWhere([$field . " $op" => new IdentifierExpression($selected[$i])]);
}
- $value->select(new IdentifierExpression(1), true);
- $expression->field(new IdentifierExpression('1'));
+ $value->select($true, true);
+ $expression->field($true);
$expression->type('=');
return;
}
$surrogate = $query->connection()
->newQuery()
- ->select(new IdentifierExpression('1'));
+ ->select($true);
foreach ($value as $tuple) {
$surrogate->orWhere(function($exp) use ($fields, $tuple) {
@@ -137,7 +138,7 @@ protected function _transformTupleComparison(TupleComparison $expression, $query
});
}
- $expression->field(new IdentifierExpression('1'));
+ $expression->field($true);
$expression->value($surrogate);
$expression->type('=');
}
@@ -48,8 +48,13 @@ public function __construct($fields, $values, $types = [], $conjuntion = '=') {
public function sql(ValueBinder $generator) {
$template = '(%s) %s (%s)';
$fields = [];
+ $originalFields = $this->getField();
- foreach ((array)$this->getField() as $field) {
+ if (!is_array($originalFields)) {
+ $originalFields = [$originalFields];
+ }
+
+ foreach ($originalFields as $field) {
$fields[] = $field instanceof ExpressionInterface ? $field->sql($generator) : $field;
}

0 comments on commit af6ccdb

Please sign in to comment.