From e29be44373f856cfd29bbe2551dc48083c280fa3 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:43:25 +1200 Subject: [PATCH] MNT Don't change auto-increment for non mysql database in test (#10906) --- tests/php/ORM/DataListEagerLoadingTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/php/ORM/DataListEagerLoadingTest.php b/tests/php/ORM/DataListEagerLoadingTest.php index 7dda2ec9eb4..2871ce834b7 100644 --- a/tests/php/ORM/DataListEagerLoadingTest.php +++ b/tests/php/ORM/DataListEagerLoadingTest.php @@ -5,6 +5,7 @@ use InvalidArgumentException; use LogicException; use SilverStripe\Dev\SapphireTest; +use SilverStripe\ORM\Connect\MySQLDatabase; use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; @@ -78,6 +79,15 @@ public static function getExtraDataObjects() public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); + + // The AUTO_INCREMENT functionality isn't abstracted, and doesn't work with the same syntax in + // other database drivers. But for other drivers we don't care so much if there are overlapping + // IDs because avoiding them is only required to test the PHP logic, not the database driver + // compatibility. + if (!(DB::get_conn() instanceof MySQLDatabase)) { + return; + } + // Set non-zero auto increment offset for each object type so we don't end up with the same IDs across // the board. If all of the IDs are 0, 1, 2 then we have no way of knowing if we're accidentally mixing // up relation ID lists between different relation lists for different classes.