diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index f11e537e60e..7f9f3e79d36 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -152,6 +152,10 @@ protected function getDateArithmeticIntervalExpression($date, $operator, $interv case DateIntervalUnit::SECOND: case DateIntervalUnit::MINUTE: case DateIntervalUnit::HOUR: + if (! is_numeric($interval)) { + $interval = "' || " . $interval . " || '"; + } + return 'DATETIME(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; } diff --git a/tests/Platforms/SqlitePlatformTest.php b/tests/Platforms/SqlitePlatformTest.php index 94de2f0db73..2a105e9c4cb 100644 --- a/tests/Platforms/SqlitePlatformTest.php +++ b/tests/Platforms/SqlitePlatformTest.php @@ -733,6 +733,22 @@ public function testQuotesDropForeignKeySQL(): void $this->markTestSkipped('SQLite does not support altering foreign key constraints.'); } + public function testDateAddStaticNumberOfMinutes(): void + { + self::assertSame( + "DATETIME(endAt,'+12 MINUTE')", + $this->platform->getDateAddMinutesExpression('endAt', 12), + ); + } + + public function testDateAddNumberOfMinutesFromColumn(): void + { + self::assertSame( + "DATETIME(endAt,'+' || duration || ' MINUTE')", + $this->platform->getDateAddMinutesExpression('endAt', 'duration'), + ); + } + public function testDateAddStaticNumberOfDays(): void { self::assertSame(