1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-01 11:50:15 +02:00

added Driver::escapeDateInterval() (BC break) (#334)

This commit is contained in:
Jan Pecha
2019-08-30 18:25:15 +02:00
committed by David Grudl
parent 78d6603bb0
commit 369768a62a
11 changed files with 70 additions and 0 deletions

View File

@@ -259,6 +259,12 @@ class FirebirdDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -302,6 +302,12 @@ class MySqliDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -238,6 +238,12 @@ class OdbcDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -257,6 +257,12 @@ class OracleDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -310,6 +310,12 @@ class PdoDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -304,6 +304,12 @@ class PostgreDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -242,6 +242,12 @@ class SqliteDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -231,6 +231,12 @@ class SqlsrvDriver implements Dibi\Driver
}
public function escapeDateInterval(\DateInterval $value): string
{
throw new Dibi\NotImplementedException;
}
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -456,6 +456,9 @@ final class Translator
} elseif ($value instanceof \DateTimeInterface) {
return $this->driver->escapeDateTime($value);
} elseif ($value instanceof \DateInterval) {
return $this->driver->escapeDateInterval($value);
} elseif ($value instanceof Literal) {
return (string) $value;

View File

@@ -91,6 +91,8 @@ interface Driver
function escapeDateTime(\DateTimeInterface $value): string;
function escapeDateInterval(\DateInterval $value): string;
/**
* Encodes string for use in a LIKE statement.
*/

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new Dibi\Connection($config);
$translator = new Dibi\Translator($conn);
switch ($config['system']) {
default:
Assert::exception(function () use ($translator) {
$translator->formatValue(new DateInterval('PT10H20M30S'), null);
}, Dibi\Exception::class);
}