Fix handling of table prefix and quoting in insert_or_update()

In all places we use this function the $table argument has already
been passed through table_name() method, i.e. it contains the prefix
and is quoted. So, we should not do this again.
This commit is contained in:
Aleksander Machniak
2021-02-15 11:31:06 +01:00
parent 4e4196d01b
commit 747bcd2ff4
3 changed files with 3 additions and 6 deletions

View File

@@ -224,7 +224,7 @@ class rcube_db_mysql extends rcube_db
* INSERT ... ON DUPLICATE KEY UPDATE (or equivalent).
* When not supported by the engine we do UPDATE and INSERT.
*
* @param string $table Table name
* @param string $table Table name (should be already passed via table_name() with quoting)
* @param array $keys Hash array (column => value) of the unique constraint
* @param array $columns List of columns to update
* @param array $values List of values to update (number of elements
@@ -235,7 +235,6 @@ class rcube_db_mysql extends rcube_db
*/
public function insert_or_update($table, $keys, $columns, $values)
{
$table = $this->table_name($table, true);
$columns = array_map(function($i) { return "`$i`"; }, $columns);
$cols = implode(', ', array_map(function($i) { return "`$i`"; }, array_keys($keys)));
$cols .= ', ' . implode(', ', $columns);

View File

@@ -195,7 +195,7 @@ class rcube_db_pgsql extends rcube_db
* INSERT ... ON CONFLICT DO UPDATE.
* When not supported by the engine we do UPDATE and INSERT.
*
* @param string $table Table name
* @param string $table Table name (should be already passed via table_name() with quoting)
* @param array $keys Hash array (column => value) of the unique constraint
* @param array $columns List of columns to update
* @param array $values List of values to update (number of elements
@@ -211,7 +211,6 @@ class rcube_db_pgsql extends rcube_db
return parent::insert_or_update($table, $keys, $columns, $values);
}
$table = $this->table_name($table, true);
$columns = array_map([$this, 'quote_identifier'], $columns);
$target = implode(', ', array_map([$this, 'quote_identifier'], array_keys($keys)));
$cols = $target . ', ' . implode(', ', $columns);

View File

@@ -576,7 +576,7 @@ class rcube_db
* INSERT ... ON DUPLICATE KEY UPDATE (or equivalent).
* When not supported by the engine we do UPDATE and INSERT.
*
* @param string $table Table name
* @param string $table Table name (should be already passed via table_name() with quoting)
* @param array $keys Hash array (column => value) of the unique constraint
* @param array $columns List of columns to update
* @param array $values List of values to update (number of elements
@@ -587,7 +587,6 @@ class rcube_db
*/
public function insert_or_update($table, $keys, $columns, $values)
{
$table = $this->table_name($table, true);
$columns = array_map(function($i) { return "`$i`"; }, $columns);
$sets = array_map(function($i) { return "$i = ?"; }, $columns);
$where = $keys;