Commit af36a40c authored by Fogs's avatar Fogs

Allow dynamic intervals in DATE_ADD & DATE_SUB for SQLite

parent 63efa539
...@@ -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