Open andylibrian opened 9 years ago
hmm this is interesting .. might be a BC break in Doctrine 2.5?
@Ocramius do you have an idea why he is not getting an instance of PDOConnection from Doctrine DBAL but a raw PDO object?
Hmm I guess the reason is that Laravel is setting the PDO connection as a parameter maybe?
@andylibrian can you make the change to \PDO
in a PR so that we can see if the test suite still passes .. we might indeed simply require a too strict type hint here.
Any git changelogs for that type hint? I don't remember this changing since 2.4.x
@lsmith77 I just sent the PR and it seems like the test suite still passes. @Ocramius I browsed through the log of this repo and the type hint was already there since the first time.
I felt determined so I toke a look at Doctrine DBAL and found this, what do you guys think about it?
The error from jackalope was because $this->conn->getWrappedConnection()
returns PDO instead of DBAL PDOConnection (which the type hint requires):
// @TODO: move to "SqlitePlatform" and rename to "registerExtraFunctions"?
if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) {
$this->registerSqliteFunctions($this->conn->getWrappedConnection());
}
in Doctrine\DBAL\Connection::getWrappedConnection()
/**
* Gets the wrapped driver connection.
*
* @return \Doctrine\DBAL\Driver\Connection
*/
public function getWrappedConnection()
{
$this->connect();
return $this->_conn;
}
It says it should return \Doctrine\DBAL\Driver\Connection
from $this->_conn
, but I saw this in constructor:
public function __construct(array $params, Driver $driver, Configuration $config = null,
EventManager $eventManager = null)
{
$this->_driver = $driver;
$this->_params = $params;
if (isset($params['pdo'])) {
$this->_conn = $params['pdo'];
$this->_isConnected = true;
unset($this->_params['pdo']);
}
$this->_conn
is set from $params['pdo']
which is a PDO instance.
That might be the case? In my Laravel package, I indeed reuse the existing PDO connection (from Laravel Service Provider) and pass it to Doctrine DBAL as 'pdo' param.
Is this something related to that "TODO"?
This TODO is a reminder to clean up those "if PLATFORM then" cascades. Not related to this issue.
so there is some regression in dbal it seems. but we do need a method from PDO actually in that place. commented on the pull request.
@andylibrian great that you build a laravel module, by the way! once it is working, please do a PR to the https://github.com/phpcr/phpcr.github.io/ so that we list the module in the integrations section of the website!
I am writing a Laravel package that wraps jackalope doctrine dbal. In my test, I use pdo sqlite driver, and the test failed with following error:
Here is the build : https://travis-ci.org/ramping/laravel-jackalope-doctrine-dbal/jobs/86153727
Apparently, it's because of this:
After I read these lines:
I tried to change it to
Then the test passed. Any idea? Is this something related to that "TODO"?