Skip to content

Commit

Permalink
Fix up SQLite INSERT query generation
Browse files Browse the repository at this point in the history
The UNION ALL transformation had to be updated so it reflected the root
query type using named placeholders instead of nameless ones.
  • Loading branch information
markstory committed Sep 22, 2014
1 parent b7ae2a5 commit 6946058
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Database/Dialect/SqliteDialectTrait.php
Expand Up @@ -116,15 +116,21 @@ protected function _insertQueryTranslator($query) {

$newQuery = $query->connection()->newQuery();
$cols = $v->columns();
$placeholder = 0;
$replaceQuery = false;

foreach ($v->values() as $k => $val) {
$fillLength = count($cols) - count($val);
if ($fillLength > 0) {
$val = array_merge($val, array_fill(0, $fillLength, null));
}
$val = array_map(function ($val) {
return $val instanceof ExpressionInterface ? $val : '?';
}, $val);

foreach ($val as $col => $attr) {
if (!($attr instanceof ExpressionInterface)) {
$val[$col] = sprintf(':c%d', $placeholder);
$placeholder++;
}
}

$select = array_combine($cols, $val);
if ($k === 0) {
Expand Down

0 comments on commit 6946058

Please sign in to comment.