-
Notifications
You must be signed in to change notification settings - Fork 121
Add support for nested query in field params #300
Conversation
Add support for multi limit in nested queries; That fix need for nested queries inside field parameters;
Add support for nested query in field params;
@tptrixtop as @froschdesign mentioned before in #299 (comment) can you add test case for it, please? |
sure, i will add test for that case |
I have added tests for that case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use camelCase variable names instead of underscode_separated.
What about test case suggested in #262:
autowp@95efe84
Is it a valid case? Maybe it's worth to add it here?
@@ -50,7 +50,8 @@ protected function processLimit( | |||
return; | |||
} | |||
if ($parameterContainer) { | |||
$parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER); | |||
$param_prefix = $this->processInfo['paramPrefix']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use camelCase variable names instead of underscore_separated style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i think case with 1 query is valid, i will add it)
Done. I have added test for single nested query ( few limit case #262 ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks good for me, I would just change offset to be different in nested and main query, to make sure nothing is mixed there.
Do we have this issue only in Mysql SelectDecorator or maybe we have similar issue also on other platforms?
->columns([ | ||
'res' => $nestedSelect0, | ||
]) | ||
->limit('10')->offset('5'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would set here different offset, now we have the same as in the nested query, and it's possible that something is getting mixed, so to make it clear I would change the value.
->columns([ | ||
'res' => $nestedSelect0, | ||
]) | ||
->limit('10')->offset('5'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question also here: why these values are passed as strings, not as integers?
'res' => $nestedSelect0, | ||
'res0' => $nestedSelect1 | ||
]) | ||
->limit('10')->offset('5'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, I would change the offset, to be different than in nested queries.
… data to cover problem with mixed data.
I have remove extra quotes and change offset & limit. I did not check it for other platforms. Only for MySQL. |
Done. Only additional fix needed in Sqlite. I have fixed it & added test for that & committed; |
} | ||
|
||
return [$this->offset]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just to note that these methods are exactly the same as in:
zend-db/src/Sql/Platform/Mysql/SelectDecorator.php
Lines 41 to 76 in 4675b97
protected function processLimit( | |
PlatformInterface $platform, | |
DriverInterface $driver = null, | |
ParameterContainer $parameterContainer = null | |
) { | |
if ($this->limit === null && $this->offset !== null) { | |
return ['']; | |
} | |
if ($this->limit === null) { | |
return; | |
} | |
if ($parameterContainer) { | |
$paramPrefix = $this->processInfo['paramPrefix']; | |
$parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER); | |
return [$driver->formatParameterName('limit')]; | |
} | |
return [$this->limit]; | |
} | |
protected function processOffset( | |
PlatformInterface $platform, | |
DriverInterface $driver = null, | |
ParameterContainer $parameterContainer = null | |
) { | |
if ($this->offset === null) { | |
return; | |
} | |
if ($parameterContainer) { | |
$paramPrefix = $this->processInfo['paramPrefix']; | |
$parameterContainer->offsetSet($paramPrefix . 'offset', $this->offset, ParameterContainer::TYPE_INTEGER); | |
return [$driver->formatParameterName('offset')]; | |
} | |
return [$this->offset]; | |
} |
and the difference with parent class Select
is to not quote offset and limit values.
I think it's fine, for MySQL it was added in that commit: 91bfba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Great job @tptrixtop !
@froschdesign tests are provided now, and the fix looks good to me.
ping @ezimuel
@tptrixtop thanks! |
My pleasure, sir) |
Sorry, previous request was incorrect.
This one is correct.
Add support for multi limit in nested queries;
That fix need for nested queries inside field parameters;
In previous thread was mentioned that this is fix for that issue: #262
Fix bug for nested queries inside field parameters;