mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix SQL errors in TreeBehavior.
SQL errors were caused by escapeField() usage in TreeBehavior. Quoted fields were not correctly unquoted. Fixes #3491
This commit is contained in:
parent
bd69979deb
commit
965f0e87c5
2 changed files with 12 additions and 4 deletions
|
@ -286,9 +286,14 @@ class Sqlserver extends DboSource {
|
|||
$fieldAlias = $this->name($alias . '__' . $fields[$i]);
|
||||
} else {
|
||||
$build = explode('.', $fields[$i]);
|
||||
$this->_fieldMappings[$build[0] . '__' . $build[1]] = $fields[$i];
|
||||
$fieldName = $this->name($build[0] . '.' . $build[1]);
|
||||
$fieldAlias = $this->name(preg_replace("/^\[(.+)\]$/", "$1", $build[0]) . '__' . $build[1]);
|
||||
$build[0] = trim($build[0], '[]');
|
||||
$build[1] = trim($build[1], '[]');
|
||||
$name = $build[0] . '.' . $build[1];
|
||||
$alias = $build[0] . '__' . $build[1];
|
||||
|
||||
$this->_fieldMappings[$alias] = $name;
|
||||
$fieldName = $this->name($name);
|
||||
$fieldAlias = $this->name($alias);
|
||||
}
|
||||
if ($model->getColumnType($fields[$i]) == 'datetime') {
|
||||
$fieldName = "CONVERT(VARCHAR(20), {$fieldName}, 20)";
|
||||
|
|
|
@ -248,7 +248,10 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
|||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||
|
||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||
$data = $this->Tree->find('first', array(
|
||||
'conditions' => array($modelClass . '.name' => '1. Root'),
|
||||
'recursive' => -1
|
||||
));
|
||||
$this->Tree->id = $data[$modelClass]['id'];
|
||||
|
||||
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
|
||||
|
|
Loading…
Reference in a new issue