New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for PHQL replaces field names in where #12971 #13124
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@felixDlh Could you please cover your changes by small unit test? |
@sergeyklay Is it right for you now ? |
Merged by hand to the 3.2.x branch. Thank you |
sergeyklay
added a commit
that referenced
this pull request
Oct 21, 2017
@felixDlh Actually your patch is totally wrong --- mvc/model/query.zep 2017-10-21 15:43:41.000000000 +0300
+++ mvc/model/query.zep 2017-10-21 15:43:58.000000000 +0300
* Check if the qualified name is a column alias
*/
let sqlColumnAliases = this->_sqlColumnAliases;
if isset sqlColumnAliases[columnName] {
var domain;
- if isset sqlColumnAliases[columnName] && empty expr["domain"] {
return [
"type": "qualified",
"name": columnName
];
}
+ if isset sqlColumnAliases[columnName] && (!isset expr["domain"] || empty expr["domain"]) {
return [
"type": "qualified",
"name": columnName
];
}
let metaData = this->_metaData; as well as test --- wrong test 2017-10-21 15:43:41.000000000 +0300
+++ correct test 2017-10-21 15:43:58.000000000 +0300
***************
*** 2,10 ****
return [
// PR #13124, ISSUE #12971
! Missed space before WHERE and Robotina should be escaped
- "phql" => 'SELECT UPPER('. Robots::class . '.name) AS name FROM ' . Robots::class . 'WHERE ' . Robots::class .'.name = Robotina',
"expected" => [
- 'distinct' => 0,
'models' => [
Robots::class,
],
--- 2,9 ----
return [
// PR #13124, ISSUE #12971
+ "phql" => 'SELECT UPPER('. Robots::class . '.name) AS name FROM ' . Robots::class . ' WHERE ' . Robots::class .'.name = "Robotina"',
"expected" => [
'models' => [
Robots::class,
],
***************
*** 12,18 ****
'robots'
],
'columns' => [
! Why???
- 'id' => [
'type' => 'scalar',
'balias' => 'name',
'sqlAlias' => 'name',
--- 11,17 ----
'robots'
],
'columns' => [
+ 'name' => [
'type' => 'scalar',
'balias' => 'name',
'sqlAlias' => 'name',
***************
*** 41,47 ****
],
'right' => [
'type' => 'literal',
- 'value' => 'Robotina'
]
]
]
--- 40,46 ----
],
'right' => [
'type' => 'literal',
+ 'value' => '\'Robotina\''
]
]
] |
sergeyklay
added a commit
that referenced
this pull request
Oct 21, 2017
chilimatic
pushed a commit
to chilimatic/cphalcon
that referenced
this pull request
Nov 2, 2017
chilimatic
pushed a commit
to chilimatic/cphalcon
that referenced
this pull request
Nov 2, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
This PR concern issue #12971. While using your framework in a project, we encoutered the same problem as described in the issue. This solution worked for us.
Thanks