mirror of
https://github.com/dg/dibi.git
synced 2025-08-30 09:19:48 +02:00
SqlsrvDriver::applyLimit(): fixed limit and offset behaviour for odbc 11+
SqlsrvReflector: changed constrains metadata loading from INFORMATION_SCHEMA to sys schema to get complete list of all constraints, not PK only
This commit is contained in:
@@ -9,7 +9,10 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$tests = function ($conn) {
|
||||
$version = $conn->getDriver()->getResource()->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
$resource = $conn->getDriver()->getResource();
|
||||
$version = is_resource($resource)
|
||||
? sqlsrv_server_info($resource)['SQLServerVersion']
|
||||
: $resource->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
|
||||
// MsSQL2012+
|
||||
if (version_compare($version, '11.0') >= 0) {
|
||||
@@ -32,31 +35,43 @@ $tests = function ($conn) {
|
||||
);
|
||||
|
||||
// Offset invalid
|
||||
Assert::same(
|
||||
'SELECT 1',
|
||||
$conn->translate('SELECT 1 %ofs', -10)
|
||||
Assert::error(
|
||||
function () use ($conn) {
|
||||
$conn->translate('SELECT 1 %ofs', -10);
|
||||
},
|
||||
'Dibi\NotSupportedException',
|
||||
'Negative offset or limit.'
|
||||
);
|
||||
|
||||
// Limit invalid
|
||||
Assert::same(
|
||||
'SELECT 1',
|
||||
$conn->translate('SELECT 1 %lmt', -10)
|
||||
Assert::error(
|
||||
function () use ($conn) {
|
||||
$conn->translate('SELECT 1 %lmt', -10);
|
||||
},
|
||||
'Dibi\NotSupportedException',
|
||||
'Negative offset or limit.'
|
||||
);
|
||||
|
||||
// Limit invalid, offset valid
|
||||
Assert::same(
|
||||
'SELECT 1',
|
||||
$conn->translate('SELECT 1 %ofs %lmt', 10, -10)
|
||||
Assert::error(
|
||||
function () use ($conn) {
|
||||
$conn->translate('SELECT 1 %ofs %lmt', 10, -10);
|
||||
},
|
||||
'Dibi\NotSupportedException',
|
||||
'Negative offset or limit.'
|
||||
);
|
||||
|
||||
// Limit valid, offset invalid
|
||||
Assert::same(
|
||||
'SELECT 1',
|
||||
$conn->translate('SELECT 1 %ofs %lmt', -10, 10)
|
||||
Assert::error(
|
||||
function () use ($conn) {
|
||||
$conn->translate('SELECT 1 %ofs %lmt', -10, 10);
|
||||
},
|
||||
'Dibi\NotSupportedException',
|
||||
'Negative offset or limit.'
|
||||
);
|
||||
} else {
|
||||
Assert::same(
|
||||
'SELECT TOP 1 * FROM (SELECT 1) t',
|
||||
'SELECT TOP (1) * FROM (SELECT 1) t',
|
||||
$conn->translate('SELECT 1 %lmt', 1)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user