Skip to content

Commit d5cdee9

Browse files
authored
Update PostgresDriver.php
fix: connect方法校验的类型必须是PostgreSQL,然而在之前hyperf/database处理时出来的pdo类型是PDO,导致migration时变更(change)字段时出现报错。 只有变更字段时会直接调用“doctrine/dbal”获得SQL语句,create table等migration动作时都是本仓库完成的,所以直接修改为按照hyperf/database的mysql一样返回PDO类型。经测试,能正常使用。
1 parent 7bb3ae4 commit d5cdee9

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/DBAL/PostgresDriver.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,9 @@
1313
namespace Hyperf\Database\PgSQL\DBAL;
1414

1515
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
16-
use InvalidArgumentException;
17-
use Swoole\Coroutine\PostgreSQL;
16+
use Hyperf\Database\DBAL\Concerns\ConnectsToDatabase;
1817

1918
class PostgresDriver extends AbstractPostgreSQLDriver
2019
{
21-
/**
22-
* Create a new database connection.
23-
*/
24-
public function connect(array $params)
25-
{
26-
if (! isset($params['pdo']) || ! $params['pdo'] instanceof PostgreSQL) {
27-
throw new InvalidArgumentException('The "pdo" property must be required.');
28-
}
29-
30-
return new Connection($params['pdo']);
31-
}
20+
use ConnectsToDatabase;
3221
}

0 commit comments

Comments
 (0)