Commit 3e0a4946 authored by Sergei Morozov's avatar Sergei Morozov Committed by Marco Pivetta

[DBAL-2546] Fixed the failure of `Functional\StatementTest::testFetchLongBlob()` on pdo_sqlsrv

The test is partially skipped due to:

1. Fetching blob as binary string from pdo_sqlsrv requires using `PDOStatement::bindColumn()` and `PDOStatement::fetch(PDO::FETCH_BIND)` which are not supported by the DBAL.
2. Setting encoding on the connection level is not supported: https://msdn.microsoft.com/en-us/library/ff628164(v=sql.105).aspx
parent 16ec3379
......@@ -28,6 +28,15 @@ use Doctrine\DBAL\Driver\PDOConnection;
*/
class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connection
{
/**
* {@inheritdoc}
*/
public function __construct($dsn, $user = null, $password = null, array $options = null)
{
parent::__construct($dsn, $user, $password, $options);
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array(Statement::class, array()));
}
/**
* @override
*/
......
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver\PDOStatement;
use PDO;
/**
* PDO SQL Server Statement
*/
class Statement extends PDOStatement
{
/**
* {@inheritdoc}
*/
public function bindParam($column, &$variable, $type = PDO::PARAM_STR, $length = null, $driverOptions = null)
{
if ($type === PDO::PARAM_LOB && $driverOptions === null) {
$driverOptions = PDO::SQLSRV_ENCODING_BINARY;
}
return parent::bindParam($column, $variable, $type, $length, $driverOptions);
}
/**
* {@inheritdoc}
*/
public function bindValue($param, $value, $type = PDO::PARAM_STR)
{
return $this->bindParam($param, $value, $type);
}
}
......@@ -113,6 +113,11 @@ EOF
$stmt->fetchColumn(),
$this->_conn->getDatabasePlatform()
);
if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') {
$this->markTestSkipped('Skipping on pdo_sqlsrv due to https://github.com/Microsoft/msphpsql/issues/270');
}
$this->assertSame($contents, stream_get_contents($stream));
}
......
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