Skip to content

Commit

Permalink
Fixes #12971
Browse files Browse the repository at this point in the history
Refs: #13124
  • Loading branch information
sergeyklay committed Oct 21, 2017
1 parent 07f02ab commit 85d87d2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-3.2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [3.2.4](https://github.com/phalcon/cphalcon/releases/tag/v3.2.4) (2017-21-12)
- Fixed regression of [#13046](https://github.com/phalcon/cphalcon/issues/13046) by removing injection of dispatcher's parameters (which were never available anyway) [#13121](https://github.com/phalcon/cphalcon/issues/13121)
- Fixed `Phalcon/Mvc/Model/Query::_getQualified` to correct replace field names in `WHERE` [#12971](https://github.com/phalcon/cphalcon/issues/12971)

# [3.2.3](https://github.com/phalcon/cphalcon/releases/tag/v3.2.3) (2017-10-12)
- Fixed `Phalcon\Mvc\Model\Query::_executeSelect` threw RuntimeException, if db:beforeQuery() returned false
Expand Down
12 changes: 8 additions & 4 deletions phalcon/mvc/model/query.zep
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ class Query implements QueryInterface, InjectionAwareInterface
*/
let sqlColumnAliases = this->_sqlColumnAliases;
if isset sqlColumnAliases[columnName] {
return [
"type": "qualified",
"name": columnName
];
var domain;

if !fetch domain, expr["domain"] {
return [
"type": "qualified",
"name": columnName
];
}
}

let metaData = this->_metaData;
Expand Down
47 changes: 47 additions & 0 deletions tests/unit/Mvc/Model/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6914,7 +6914,54 @@ function ($phql, $expected) {
),
),
)
],
[
// PR #13124, ISSUE #12971
"phql" => 'SELECT UPPER('. Robots::class . '.name) AS name FROM ' . Robots::class . 'WHERE ' . Robots::class .'.name = Robotina',
"expected" => [
'distinct' => 0,
'models' => [
Robots::class,
],
'tables' => [
'robots'
],
'columns' => [
'id' => [
'type' => 'scalar',
'balias' => 'name',
'sqlAlias' => 'name',
'column' => [
'type' => 'functionCall',
'name' => 'UPPER',
'arguments' => [
[
'type' => 'qualified',
'domain' => 'robots',
'name' => 'name',
'balias' => 'name'
]
],
],
]
],
'where' => [
'type' => 'binary-op',
'op' => '=',
'left' => [
'type' => 'qualified',
'domain' => 'robots',
'name' => 'name',
'balias' => 'name'
],
'right' => [
'type' => 'literal',
'value' => 'Robotina'
]
]
]
]

]
]
);
Expand Down

0 comments on commit 85d87d2

Please sign in to comment.