mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 20:57:36 +02:00
added Driver::escapeDateInterval() (BC break) (#334)
This commit is contained in:
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -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.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
@@ -456,6 +456,9 @@ final class Translator
|
|||||||
} elseif ($value instanceof \DateTimeInterface) {
|
} elseif ($value instanceof \DateTimeInterface) {
|
||||||
return $this->driver->escapeDateTime($value);
|
return $this->driver->escapeDateTime($value);
|
||||||
|
|
||||||
|
} elseif ($value instanceof \DateInterval) {
|
||||||
|
return $this->driver->escapeDateInterval($value);
|
||||||
|
|
||||||
} elseif ($value instanceof Literal) {
|
} elseif ($value instanceof Literal) {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
|
|
||||||
|
@@ -91,6 +91,8 @@ interface Driver
|
|||||||
|
|
||||||
function escapeDateTime(\DateTimeInterface $value): string;
|
function escapeDateTime(\DateTimeInterface $value): string;
|
||||||
|
|
||||||
|
function escapeDateInterval(\DateInterval $value): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
*/
|
*/
|
||||||
|
17
tests/dibi/Translator.DateInterval.phpt
Normal file
17
tests/dibi/Translator.DateInterval.phpt
Normal 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);
|
||||||
|
}
|
Reference in New Issue
Block a user