Unverified Commit 73a466ae authored by Ashley Dawson's avatar Ashley Dawson Committed by Sergei Morozov

Added functional test for date arithmetic using a column reference for SQLite

parent 79c732ba
......@@ -5,7 +5,9 @@ namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\TrimMode;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use const PHP_EOL;
......@@ -569,6 +571,34 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), "Subtracting years should end up on 2004-01-01");
}
public function testSqliteDateArithmeticWithDynamicInterval()
{
$platform = $this->_conn->getDatabasePlatform();
if (! $platform instanceof SqlitePlatform) {
$this->markTestSkipped('test is for sqlite only');
}
$table = new Table('fetch_table_date_math');
$table->addColumn('test_date', 'date');
$table->addColumn('test_days', 'integer');
$table->setPrimaryKey(['test_date']);
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$sm = $this->_conn->getSchemaManager();
$sm->createTable($table);
$this->_conn->insert('fetch_table_date_math', ['test_date' => '2010-01-01', 'test_days' => 10]);
$this->_conn->insert('fetch_table_date_math', ['test_date' => '2010-06-01', 'test_days' => 20]);
$sql = 'SELECT COUNT(*) FROM fetch_table_date_math WHERE ';
$sql .= $platform->getDateSubDaysExpression('test_date', 'test_days') . " < '2010-05-12'";
$rowCount = $this->_conn->fetchColumn($sql, [], 0);
$this->assertEquals(1, $rowCount);
}
public function testLocateExpression()
{
$platform = $this->_conn->getDatabasePlatform();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment