Skip to content
Permalink
Browse files

Fix issue with identifier quoting.

Code from `master` broke type mappers that convert to expression
objects. Because the columns are now actually replaced when
$query->insert() is called multiple times, we also need to strip quoting
from the code that converts values into expressions.
  • Loading branch information...
markstory committed May 27, 2016
1 parent 05fa655 commit c6a93d9db34c7712d5c7c3827a00fb6d049e2faf
Showing with 20 additions and 5 deletions.
  1. +20 −5 src/Database/Expression/ValuesExpression.php
@@ -118,6 +118,23 @@ public function columns($cols = null)
return $this;
}
/**
* Get the bare column names.
*
* Because column names could be identifier quoted, we
* need to strip the identifiers off of the columns.
*
* @return array
*/
protected function _columnNames()
{
$columns = [];
foreach ($this->_columns as $col) {
$columns[] = trim($col, '`[]"');
}
return $columns;
}
/**
* Sets the values to be inserted. If no params are passed, then it returns
* the currently stored values
@@ -173,10 +190,7 @@ public function sql(ValueBinder $generator)
$i = 0;
$columns = [];
// Remove identifier quoting so column names match keys.
foreach ($this->_columns as $col) {
$columns[] = trim($col, '`[]"');
}
$columns = $this->_columnNames();
$defaults = array_fill_keys($columns, null);
$placeholders = [];
@@ -257,7 +271,8 @@ protected function _processExpressions()
$types = [];
$typeMap = $this->typeMap();
foreach ($this->_columns as $c) {
$columns = $this->_columnNames();
foreach ($columns as $c) {
if (!is_scalar($c)) {
continue;
}

0 comments on commit c6a93d9

Please sign in to comment.
You can’t perform that action at this time.