Unverified Commit 93f89e3f authored by Marco Pivetta's avatar Marco Pivetta Committed by Sergei Morozov

Merge pull request #3498 from morozov/get-other-expr

Reworked AbstractPlatform::get*Expression() methods
parents 91ede91a 8d4d457c
# Upgrade to 3.0 # Upgrade to 3.0
## BC BREAK `AbstractPlatform::get*Expression()` methods no loner accept integer values as arguments
The following methods' arguments do not longer accept integer value:
- the `$expression` argument in `::getCountExpression()`,
- the `$decimals` argument in `::getRoundExpression()`,
- the `$seconds` argument in `::getDateAddSecondsExpression()`,
- the `$seconds` argument in `::getDateSubSecondsExpression()`,
- the `$minutes` argument in `::getDateAddMinutesExpression()`,
- the `$minutes` argument in `::getDateSubMinutesExpression()`,
- the `$hours` argument in `::getDateAddHourExpression()`,
- the `$hours` argument in `::getDateAddHourExpression()`,
- the `$days` argument in `::getDateAddDaysExpression()`,
- the `$days` argument in `::getDateSubDaysExpression()`,
- the `$weeks` argument in `::getDateAddWeeksExpression()`,
- the `$weeks` argument in `::getDateSubWeeksExpression()`,
- the `$months` argument in `::getDateAddMonthExpression()`,
- the `$months` argument in `::getDateSubMonthExpression()`,
- the `$quarters` argument in `::getDateAddQuartersExpression()`,
- the `$quarters` argument in `::getDateSubQuartersExpression()`,
- the `$years` argument in `::getDateAddYearsExpression()`,
- the `$years` argument in `::getDateSubYearsExpression()`.
Please use the strings representing numeric SQL literals instead (e.g. `'1'` instead of `1`).
The signature of `AbstractPlatform::getConcatExpression()` changed to `::getConcatExpression(string ...$string)`.
## BC BREAK The type of `$start` in `AbstractPlatform::getLocateExpression()` changed from `string|false` to `?string` ## BC BREAK The type of `$start` in `AbstractPlatform::getLocateExpression()` changed from `string|false` to `?string`
The default value of `$start` is now `null`, not `false`. The default value of `$start` is now `null`, not `false`.
......
...@@ -186,7 +186,7 @@ class DB2Platform extends AbstractPlatform ...@@ -186,7 +186,7 @@ class DB2Platform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getBitAndComparisonExpression($value1, $value2) public function getBitAndComparisonExpression(string $value1, string $value2) : string
{ {
return 'BITAND(' . $value1 . ', ' . $value2 . ')'; return 'BITAND(' . $value1 . ', ' . $value2 . ')';
} }
...@@ -194,7 +194,7 @@ class DB2Platform extends AbstractPlatform ...@@ -194,7 +194,7 @@ class DB2Platform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getBitOrComparisonExpression($value1, $value2) public function getBitOrComparisonExpression(string $value1, string $value2) : string
{ {
return 'BITOR(' . $value1 . ', ' . $value2 . ')'; return 'BITOR(' . $value1 . ', ' . $value2 . ')';
} }
...@@ -202,17 +202,17 @@ class DB2Platform extends AbstractPlatform ...@@ -202,17 +202,17 @@ class DB2Platform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
switch ($unit) { switch ($unit) {
case DateIntervalUnit::WEEK: case DateIntervalUnit::WEEK:
$interval *= 7; $interval = $this->multiplyInterval($interval, 7);
$unit = DateIntervalUnit::DAY; $unit = DateIntervalUnit::DAY;
break; break;
case DateIntervalUnit::QUARTER: case DateIntervalUnit::QUARTER:
$interval *= 3; $interval = $this->multiplyInterval($interval, 3);
$unit = DateIntervalUnit::MONTH; $unit = DateIntervalUnit::MONTH;
break; break;
} }
...@@ -222,7 +222,7 @@ class DB2Platform extends AbstractPlatform ...@@ -222,7 +222,7 @@ class DB2Platform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return 'DAYS(' . $date1 . ') - DAYS(' . $date2 . ')'; return 'DAYS(' . $date1 . ') - DAYS(' . $date2 . ')';
} }
......
...@@ -16,7 +16,6 @@ use function array_merge; ...@@ -16,7 +16,6 @@ use function array_merge;
use function array_unique; use function array_unique;
use function array_values; use function array_values;
use function count; use function count;
use function func_get_args;
use function implode; use function implode;
use function in_array; use function in_array;
use function is_numeric; use function is_numeric;
...@@ -73,7 +72,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -73,7 +72,7 @@ class MySqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getRegexpExpression() public function getRegexpExpression() : string
{ {
return 'RLIKE'; return 'RLIKE';
} }
...@@ -93,15 +92,15 @@ class MySqlPlatform extends AbstractPlatform ...@@ -93,15 +92,15 @@ class MySqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getConcatExpression() public function getConcatExpression(string ...$string) : string
{ {
return sprintf('CONCAT(%s)', implode(', ', func_get_args())); return sprintf('CONCAT(%s)', implode(', ', $string));
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
$function = $operator === '+' ? 'DATE_ADD' : 'DATE_SUB'; $function = $operator === '+' ? 'DATE_ADD' : 'DATE_SUB';
...@@ -111,7 +110,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -111,7 +110,7 @@ class MySqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')'; return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
} }
......
...@@ -59,7 +59,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -59,7 +59,7 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getNowExpression($type = 'timestamp') public function getNowExpression($type = 'timestamp') : string
{ {
switch ($type) { switch ($type) {
case 'date': case 'date':
...@@ -85,7 +85,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -85,7 +85,7 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
switch ($unit) { switch ($unit) {
case DateIntervalUnit::MONTH: case DateIntervalUnit::MONTH:
...@@ -93,11 +93,11 @@ class OraclePlatform extends AbstractPlatform ...@@ -93,11 +93,11 @@ class OraclePlatform extends AbstractPlatform
case DateIntervalUnit::YEAR: case DateIntervalUnit::YEAR:
switch ($unit) { switch ($unit) {
case DateIntervalUnit::QUARTER: case DateIntervalUnit::QUARTER:
$interval *= 3; $interval = $this->multiplyInterval($interval, 3);
break; break;
case DateIntervalUnit::YEAR: case DateIntervalUnit::YEAR:
$interval *= 12; $interval = $this->multiplyInterval($interval, 12);
break; break;
} }
...@@ -131,7 +131,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -131,7 +131,7 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return sprintf('TRUNC(%s) - TRUNC(%s)', $date1, $date2); return sprintf('TRUNC(%s) - TRUNC(%s)', $date1, $date2);
} }
...@@ -139,7 +139,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -139,7 +139,7 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getBitAndComparisonExpression($value1, $value2) public function getBitAndComparisonExpression(string $value1, string $value2) : string
{ {
return 'BITAND(' . $value1 . ', ' . $value2 . ')'; return 'BITAND(' . $value1 . ', ' . $value2 . ')';
} }
...@@ -147,7 +147,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -147,7 +147,7 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getBitOrComparisonExpression($value1, $value2) public function getBitOrComparisonExpression(string $value1, string $value2) : string
{ {
return '(' . $value1 . '-' . return '(' . $value1 . '-' .
$this->getBitAndComparisonExpression($value1, $value2) $this->getBitAndComparisonExpression($value1, $value2)
......
...@@ -78,7 +78,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -78,7 +78,7 @@ class PostgreSqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getNowExpression() public function getNowExpression() : string
{ {
return 'LOCALTIMESTAMP(0)'; return 'LOCALTIMESTAMP(0)';
} }
...@@ -86,7 +86,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -86,7 +86,7 @@ class PostgreSqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getRegexpExpression() public function getRegexpExpression() : string
{ {
return 'SIMILAR TO'; return 'SIMILAR TO';
} }
...@@ -108,11 +108,11 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -108,11 +108,11 @@ class PostgreSqlPlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
if ($unit === DateIntervalUnit::QUARTER) { if ($unit === DateIntervalUnit::QUARTER) {
$interval *= 3; $interval = $this->multiplyInterval($interval, 3);
$unit = DateIntervalUnit::MONTH; $unit = DateIntervalUnit::MONTH;
} }
return '(' . $date . ' ' . $operator . ' (' . $interval . " || ' " . $unit . "')::interval)"; return '(' . $date . ' ' . $operator . ' (' . $interval . " || ' " . $unit . "')::interval)";
...@@ -121,7 +121,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -121,7 +121,7 @@ class PostgreSqlPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return '(DATE(' . $date1 . ')-DATE(' . $date2 . '))'; return '(DATE(' . $date1 . ')-DATE(' . $date2 . '))';
} }
......
...@@ -21,7 +21,6 @@ use function array_unique; ...@@ -21,7 +21,6 @@ use function array_unique;
use function array_values; use function array_values;
use function count; use function count;
use function explode; use function explode;
use function func_get_args;
use function get_class; use function get_class;
use function implode; use function implode;
use function in_array; use function in_array;
...@@ -373,9 +372,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -373,9 +372,9 @@ class SQLAnywherePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getConcatExpression() public function getConcatExpression(string ...$string) : string
{ {
return 'STRING(' . implode(', ', (array) func_get_args()) . ')'; return 'STRING(' . implode(', ', $string) . ')';
} }
/** /**
...@@ -470,7 +469,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -470,7 +469,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
$factorClause = ''; $factorClause = '';
...@@ -484,7 +483,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -484,7 +483,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return 'DATEDIFF(day, ' . $date2 . ', ' . $date1 . ')'; return 'DATEDIFF(day, ' . $date2 . ', ' . $date1 . ')';
} }
...@@ -986,15 +985,15 @@ SQL ...@@ -986,15 +985,15 @@ SQL
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getMd5Expression($column) public function getMd5Expression(string $string) : string
{ {
return 'HASH(' . $column . ", 'MD5')"; return 'HASH(' . $string . ", 'MD5')";
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRegexpExpression() public function getRegexpExpression() : string
{ {
return 'REGEXP'; return 'REGEXP';
} }
......
...@@ -18,7 +18,6 @@ use function count; ...@@ -18,7 +18,6 @@ use function count;
use function crc32; use function crc32;
use function dechex; use function dechex;
use function explode; use function explode;
use function func_get_args;
use function implode; use function implode;
use function in_array; use function in_array;
use function is_array; use function is_array;
...@@ -74,7 +73,7 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -74,7 +73,7 @@ class SQLServerPlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
$factorClause = ''; $factorClause = '';
...@@ -88,7 +87,7 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -88,7 +87,7 @@ class SQLServerPlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return 'DATEDIFF(day, ' . $date2 . ',' . $date1 . ')'; return 'DATEDIFF(day, ' . $date2 . ',' . $date1 . ')';
} }
...@@ -1028,9 +1027,9 @@ SQL ...@@ -1028,9 +1027,9 @@ SQL
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getModExpression($expression1, $expression2) public function getModExpression(string $dividend, string $divisor) : string
{ {
return $expression1 . ' % ' . $expression2; return $dividend . ' % ' . $divisor;
} }
/** /**
...@@ -1082,11 +1081,9 @@ SQL ...@@ -1082,11 +1081,9 @@ SQL
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getConcatExpression() public function getConcatExpression(string ...$string) : string
{ {
$args = func_get_args(); return '(' . implode(' + ', $string) . ')';
return '(' . implode(' + ', $args) . ')';
} }
/** /**
...@@ -1120,9 +1117,9 @@ SQL ...@@ -1120,9 +1117,9 @@ SQL
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getLengthExpression($column) public function getLengthExpression(string $string) : string
{ {
return 'LEN(' . $column . ')'; return 'LEN(' . $string . ')';
} }
/** /**
......
...@@ -17,7 +17,6 @@ use function array_merge; ...@@ -17,7 +17,6 @@ use function array_merge;
use function array_unique; use function array_unique;
use function array_values; use function array_values;
use function implode; use function implode;
use function is_numeric;
use function sprintf; use function sprintf;
use function sqrt; use function sqrt;
use function str_replace; use function str_replace;
...@@ -37,7 +36,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -37,7 +36,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getRegexpExpression() public function getRegexpExpression() : string
{ {
return 'REGEXP'; return 'REGEXP';
} }
...@@ -45,7 +44,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -45,7 +44,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getNowExpression($type = 'timestamp') public function getNowExpression($type = 'timestamp') : string
{ {
switch ($type) { switch ($type) {
case 'time': case 'time':
...@@ -122,39 +121,31 @@ class SqlitePlatform extends AbstractPlatform ...@@ -122,39 +121,31 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) protected function getDateArithmeticIntervalExpression(string $date, string $operator, string $interval, string $unit) : string
{ {
switch ($unit) { switch ($unit) {
case DateIntervalUnit::SECOND: case DateIntervalUnit::WEEK:
case DateIntervalUnit::MINUTE: $interval = $this->multiplyInterval($interval, 7);
case DateIntervalUnit::HOUR: $unit = DateIntervalUnit::DAY;
return 'DATETIME(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; break;
default:
switch ($unit) {
case DateIntervalUnit::WEEK:
$interval *= 7;
$unit = DateIntervalUnit::DAY;
break;
case DateIntervalUnit::QUARTER:
$interval *= 3;
$unit = DateIntervalUnit::MONTH;
break;
}
if (! is_numeric($interval)) {
$interval = "' || " . $interval . " || '";
}
return 'DATE(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; case DateIntervalUnit::QUARTER:
$interval = $this->multiplyInterval($interval, 3);
$unit = DateIntervalUnit::MONTH;
break;
} }
return 'DATETIME(' . $date . ',' . $this->getConcatExpression(
$this->quoteStringLiteral($operator),
$interval,
$this->quoteStringLiteral(' ' . $unit)
) . ')';
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getDateDiffExpression($date1, $date2) public function getDateDiffExpression(string $date1, string $date2) : string
{ {
return sprintf("JULIANDAY(%s, 'start of day') - JULIANDAY(%s, 'start of day')", $date1, $date2); return sprintf("JULIANDAY(%s, 'start of day') - JULIANDAY(%s, 'start of day')", $date1, $date2);
} }
......
...@@ -348,18 +348,18 @@ class DB2PlatformTest extends AbstractPlatformTestCase ...@@ -348,18 +348,18 @@ class DB2PlatformTest extends AbstractPlatformTestCase
self::assertEquals("'1987/05/02' + 12 HOUR", $this->platform->getDateAddHourExpression("'1987/05/02'", 12)); self::assertEquals("'1987/05/02' + 12 HOUR", $this->platform->getDateAddHourExpression("'1987/05/02'", 12));
self::assertEquals("'1987/05/02' + 2 MINUTE", $this->platform->getDateAddMinutesExpression("'1987/05/02'", 2)); self::assertEquals("'1987/05/02' + 2 MINUTE", $this->platform->getDateAddMinutesExpression("'1987/05/02'", 2));
self::assertEquals("'1987/05/02' + 102 MONTH", $this->platform->getDateAddMonthExpression("'1987/05/02'", 102)); self::assertEquals("'1987/05/02' + 102 MONTH", $this->platform->getDateAddMonthExpression("'1987/05/02'", 102));
self::assertEquals("'1987/05/02' + 15 MONTH", $this->platform->getDateAddQuartersExpression("'1987/05/02'", 5)); self::assertEquals("'1987/05/02' + (5 * 3) MONTH", $this->platform->getDateAddQuartersExpression("'1987/05/02'", 5));
self::assertEquals("'1987/05/02' + 1 SECOND", $this->platform->getDateAddSecondsExpression("'1987/05/02'", 1)); self::assertEquals("'1987/05/02' + 1 SECOND", $this->platform->getDateAddSecondsExpression("'1987/05/02'", 1));
self::assertEquals("'1987/05/02' + 21 DAY", $this->platform->getDateAddWeeksExpression("'1987/05/02'", 3)); self::assertEquals("'1987/05/02' + (3 * 7) DAY", $this->platform->getDateAddWeeksExpression("'1987/05/02'", 3));
self::assertEquals("'1987/05/02' + 10 YEAR", $this->platform->getDateAddYearsExpression("'1987/05/02'", 10)); self::assertEquals("'1987/05/02' + 10 YEAR", $this->platform->getDateAddYearsExpression("'1987/05/02'", 10));
self::assertEquals("DAYS('1987/05/02') - DAYS('1987/04/01')", $this->platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'")); self::assertEquals("DAYS('1987/05/02') - DAYS('1987/04/01')", $this->platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
self::assertEquals("'1987/05/02' - 4 DAY", $this->platform->getDateSubDaysExpression("'1987/05/02'", 4)); self::assertEquals("'1987/05/02' - 4 DAY", $this->platform->getDateSubDaysExpression("'1987/05/02'", 4));
self::assertEquals("'1987/05/02' - 12 HOUR", $this->platform->getDateSubHourExpression("'1987/05/02'", 12)); self::assertEquals("'1987/05/02' - 12 HOUR", $this->platform->getDateSubHourExpression("'1987/05/02'", 12));
self::assertEquals("'1987/05/02' - 2 MINUTE", $this->platform->getDateSubMinutesExpression("'1987/05/02'", 2)); self::assertEquals("'1987/05/02' - 2 MINUTE", $this->platform->getDateSubMinutesExpression("'1987/05/02'", 2));
self::assertEquals("'1987/05/02' - 102 MONTH", $this->platform->getDateSubMonthExpression("'1987/05/02'", 102)); self::assertEquals("'1987/05/02' - 102 MONTH", $this->platform->getDateSubMonthExpression("'1987/05/02'", 102));
self::assertEquals("'1987/05/02' - 15 MONTH", $this->platform->getDateSubQuartersExpression("'1987/05/02'", 5)); self::assertEquals("'1987/05/02' - (5 * 3) MONTH", $this->platform->getDateSubQuartersExpression("'1987/05/02'", 5));
self::assertEquals("'1987/05/02' - 1 SECOND", $this->platform->getDateSubSecondsExpression("'1987/05/02'", 1)); self::assertEquals("'1987/05/02' - 1 SECOND", $this->platform->getDateSubSecondsExpression("'1987/05/02'", 1));
self::assertEquals("'1987/05/02' - 21 DAY", $this->platform->getDateSubWeeksExpression("'1987/05/02'", 3)); self::assertEquals("'1987/05/02' - (3 * 7) DAY", $this->platform->getDateSubWeeksExpression("'1987/05/02'", 3));
self::assertEquals("'1987/05/02' - 10 YEAR", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10)); self::assertEquals("'1987/05/02' - 10 YEAR", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10));
self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->platform->getForUpdateSQL()); self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->platform->getForUpdateSQL());
self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column')); self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
......
...@@ -791,12 +791,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -791,12 +791,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
public function testDateAddStaticNumberOfDays() : void public function testDateAddStaticNumberOfDays() : void
{ {
self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 12)); self::assertSame("DATETIME(rentalBeginsOn,'+' || 12 || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 12));
} }
public function testDateAddNumberOfDaysFromColumn() : void public function testDateAddNumberOfDaysFromColumn() : void
{ {
self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 'duration')); self::assertSame("DATETIME(rentalBeginsOn,'+' || duration || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 'duration'));
} }
public function testSupportsColumnCollation() : void public function testSupportsColumnCollation() : void
......
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