php-mysql-engine icon indicating copy to clipboard operation
php-mysql-engine copied to clipboard

WIP: Add an UPDATE with ORDER BY that fails.

Open rguico opened this issue 1 year ago • 1 comments

This PR demonstrates a corner case that we use in our code, where UPDATE is used with ORDER BY. I'm not sure how to resolve it, so it's a WIP.

The root cause is that ORDER BY causes the row index to reset in this statement:

return new QueryResult(array_values($rows), $result->columns);

However, removing array_values causes errors in other tests!

rguico avatar Mar 07 '24 16:03 rguico

Error caused:

/opt/homebrew/bin/php php-mysql-engine/vendor/phpunit/phpunit/phpunit --configuration php-mysql-engine/phpunit.xml.dist --filter "/(Vimeo\\MysqlEngine\\Tests\\EndToEndTest::testUpdateWithOrderAndPrimaryKey)( .*)?$/" --test-suffix EndToEndTest.php php-mysql-engine/tests --teamcity
Testing started at 10:38 AM ...
Cannot load Xdebug - it was already loaded
PHPUnit 9.6.17 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.1
Configuration: php-mysql-engine/phpunit.xml.dist
Random Seed:   1709829489


Vimeo\MysqlEngine\Processor\SQLFakeUniqueKeyViolation : Duplicate entry '7' for key 'PRIMARY' in table 'video_game_characters'
 php-mysql-engine/src/Processor/Processor.php:226
 php-mysql-engine/src/Processor/UpdateProcessor.php:25
 php-mysql-engine/src/FakePdoStatementTrait.php:237
 php-mysql-engine/src/Php8/FakePdoStatement.php:16
php-mysql-engine/src/FakePdoTrait.php:185
php-mysql-engine/tests/EndToEndTest.php:1144

rguico avatar Mar 07 '24 16:03 rguico