Unverified Commit a4015c8b authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #3019 from fogs/date_add

Allow dynamic intervals in DATE_ADD & DATE_SUB for SQLite
parents 792c5b5e 968e6a56
...@@ -150,6 +150,10 @@ class SqlitePlatform extends AbstractPlatform ...@@ -150,6 +150,10 @@ class SqlitePlatform extends AbstractPlatform
break; break;
} }
if (! is_numeric($interval)) {
$interval = "' || " . $interval . " || '";
}
return "DATE(" . $date . ",'" . $operator . $interval . " " . $unit . "')"; return "DATE(" . $date . ",'" . $operator . $interval . " " . $unit . "')";
} }
} }
......
...@@ -749,4 +749,14 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -749,4 +749,14 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{ {
self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
} }
public function testDateAddStaticNumberOfDays()
{
self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 12));
}
public function testDateAddNumberOfDaysFromColumn()
{
self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 'duration'));
}
} }
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