-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fixes #5642 #5643
Fixes #5642 #5643
Conversation
Adding a group annotation on the test with the issue id is never a bad idea |
@macnibblet a group annotation added ;) |
i think the annotation must be added to the method, but i could be wrong. |
@macnibblet I'm not sure if it placed on the method because so many tests on one method. should I reset last commit ( a group annotation addition ) ? |
Looks spot-on, many thanks |
if ($this->offset === null) { | ||
return null; | ||
} | ||
$this->limit = "18446744073709551615"; //maximum of unsigned BIGINT |
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.
@ralphschindler about platform specific, should it changed by :
if ($platform instanceof \Zend\Db\Sql\Platform\Mysql && $this->offset !== null) {
$this->limit = "18446744073709551615"; //maximum of unsigned BIGINT
}
return null;
is it better ?
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.
for MySql this will be overvritten by Zend\Db\Sql\Platform\Mysql\SelectDecorator
as i know - postgresql allow use offset
withot limit
as i understand - this is MySql issue - and should be fixed in Zend\Db\Sql\Platform\Mysql\SelectDecorator::processLimit
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.
@turrsis I think no, it won't be overwritten, for example :
$table = 'users';
$sampleTable = new TableGateway($table, $adapter, null,new HydratingResultSet());
$select = new Select($table);
$select->offset(10);
echo $select->getSqlString(new \Zend\Db\Adapter\Platform\Mysql);
it will get
SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 10
what case it will be overwritten with Zend\Db\Sql\Platform\Mysql\SelectDecorator
? or should I add the condition at SelectDecorator too ?
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.
$mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface');
$mockConnection = $this->getMock('Zend\Db\Adapter\Driver\ConnectionInterface');
$mockDriver->expects($this->any())->method('checkEnvironment')->will($this->returnValue(true));
$mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection));
$mockPlatform = $this->getMock('Zend\Db\Adapter\Platform\PlatformInterface');
$mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface');
$mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement));
$adapter = new \Zend\Db\Adapter\Adapter($mockDriver, $mockPlatform);
$sql = new \Zend\Db\Sql\Sql($adapter);
$sql->getSqlPlatform()->setTypeDecorator('Zend\Db\Sql\Select', new \Zend\Db\Sql\Platform\Mysql\SelectDecorator);
$query = $sql->getSqlStringForSqlObject($select46, new TrustingSql92Platform());
this code (for unitTests) use Zend\Db\Sql\Platform\Mysql\SelectDecorator::processLimit
if you code not use decorators - this is the bug, see this #5306 - this fix for decorators, subqueries, etc.
@ralphschindler are you planing to merge #5306 ?
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.
if Decorator exist - you should use it and only it, otherwise it is a bug
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.
Did you plan to move this logic to the Mysql Select decorator?
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 think the solution is to copy instead of move, because we can use new Select instead as I described above, is it ok ? @ralphschindler
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 don't think so, paging in database adapters, across the board, is already a non-standard thing. Seeing as though this is strongly a mysqlism, I think it makes the most sense to do this in the MySQL decorator. For it to be in Select, there would have to be a VERY strong argument that this particular workflow applies to most of the other popular DB platforms: postgres, sqlite, SQL Server, Db2 and Oracle.
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.
[update] I will try, but personally I don't agree to cast $limit with (int) because on some cases like this , we need big limit.... ( 18446744073709551615 ) which is not (int)
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.
@ralphschindler I have tried to move it to selectdecorator, and update SelectDecoratorTest.php, but it comes with error :
Attempting to quote a value in Zend\Db\Adapter\Platform\Mysql without extension/driver support can introduce security vulnerabilities in a production environment.
because "18446744073709551615" is quoted. because it using MysqlPlatform instead of TrustingSql92Platform, any idea ?
@ralphschindler Please set a milestone. |
@samsonasik please see #5940 |
Fixes #5642