|
|
@@ -178,6 +178,34 @@ trait SqlDialectTrait
|
|
|
if (!$hadAlias) {
|
|
|
return $query;
|
|
|
}
|
|
|
+
|
|
|
+ return $this->_removeAliasesFromConditions($query);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Apply translation steps to update queries.
|
|
|
+ *
|
|
|
+ * Chops out aliases on update query conditions as not all database dialects do support
|
|
|
+ * aliases in update queries.
|
|
|
+ *
|
|
|
+ * Just like for delete queries, joins are currently not supported for update queries.
|
|
|
+ *
|
|
|
+ * @param \Cake\Database\Query $query The query to translate
|
|
|
+ * @return \Cake\Database\Query The modified query
|
|
|
+ */
|
|
|
+ protected function _updateQueryTranslator($query)
|
|
|
+ {
|
|
|
+ return $this->_removeAliasesFromConditions($query);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Removes aliases from the `WHERE` clause of a query.
|
|
|
+ *
|
|
|
+ * @param \Cake\Database\Query $query The query to process.
|
|
|
+ * @return \Cake\Database\Query The modified query.
|
|
|
+ */
|
|
|
+ protected function _removeAliasesFromConditions($query)
|
|
|
+ {
|
|
|
$conditions = $query->clause('where');
|
|
|
if ($conditions) {
|
|
|
$conditions->traverse(function ($condition) {
|
|
|
@@ -201,17 +229,6 @@ trait SqlDialectTrait
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Apply translation steps to update queries.
|
|
|
- *
|
|
|
- * @param \Cake\Database\Query $query The query to translate
|
|
|
- * @return \Cake\Database\Query The modified query
|
|
|
- */
|
|
|
- protected function _updateQueryTranslator($query)
|
|
|
- {
|
|
|
- return $query;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Apply translation steps to insert queries.
|
|
|
*
|
|
|
* @param \Cake\Database\Query $query The query to translate
|