Skip to content

Commit

Permalink
🐛 bugfix/doctrine#6261 - Allow (also for DATETIME) dynamic intervals …
Browse files Browse the repository at this point in the history
…in DATE_ADD & DATE_SUB for SQLite

- 👌 Code review from @derrabus
  • Loading branch information
DaedalusDev committed Jan 26, 2024
1 parent 1a09101 commit 40a44fd
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions tests/Functional/Ticket/DBAL6261Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Doctrine\DBAL\Tests\Functional\Ticket;

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Types;

class DBAL6261Test extends FunctionalTestCase
{
/** @throws Exception */
protected function setUp(): void
{
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
Expand All @@ -21,10 +18,6 @@ protected function setUp(): void
self::markTestSkipped('Related to SQLite only');
}

/**
* @throws SchemaException
* @throws Exception
*/
public function testUnsignedIntegerDetection(): void
{
$testTable = 'dbal6261tbl';
Expand Down Expand Up @@ -71,7 +64,7 @@ public function testUnsignedIntegerDetection(): void
$this->connection->insert($testTableService, $wontMatch1);

$platfom = $this->connection->getDatabasePlatform();
$qb = $this->connection->createQueryBuilder()
$result = $this->connection->createQueryBuilder()
->select('s.*')
->from($testTableService, 's')
->leftJoin('s', $testTableAgency, 'a', 's.agency_id = a.id')
Expand All @@ -80,17 +73,8 @@ public function testUnsignedIntegerDetection(): void
"DATETIME('2023-01-05 15:00:00')",
'a.utc_offset',
),
);
$sql = $qb
->getSQL();
self::assertEquals(
'SELECT s.* FROM dbal6261tbl_service s '
. 'LEFT JOIN dbal6261tbl_agency a ON s.agency_id = a.id '
. "WHERE s.end_at <= DATETIME(DATETIME('2023-01-05 15:00:00'),'+' || a.utc_offset || ' MINUTE')",
$sql,
);

$result = $qb->fetchAllAssociative();
)
->fetchAllAssociative();

self::assertEquals(
[
Expand Down

0 comments on commit 40a44fd

Please sign in to comment.