Skip to content

Commit 40283de

Browse files
committed
DBAL3: More copy editing with CodeRabbit
1 parent 8d8e25f commit 40283de

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

docs/connect.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ If you plan to query CrateDB via DBAL, you can get a connection from the
2929

3030
.. code-block:: php
3131
32+
use Doctrine\DBAL\DriverManager;
33+
3234
$params = array(
3335
'driverClass' => 'Crate\DBAL\Driver\PDOCrate\Driver',
3436
'user' => 'crate',
3537
'host' => 'localhost',
3638
'port' => 4200
3739
);
38-
$connection = \Doctrine\DBAL\DriverManager::getConnection($params);
40+
$connection = DriverManager::getConnection($params);
3941
$schemaManager = $connection->createSchemaManager();
4042
4143
With these connection parameters, the ``DriverManager`` will attempt to

examples/objects.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Crate\DBAL\Types\MapType;
1818

1919
// Initialize machinery.
20+
// This ensures that the 'map' type is registered in the type system from the beginning.
2021
$platform = new CratePlatform4();
2122

2223
// Define table schema.
@@ -44,7 +45,7 @@
4445

4546
// Provision database table.
4647
try {
47-
$schemaManager->dropTable($table);
48+
$schemaManager->dropTable($table->getName());
4849
} catch (TableNotFoundException) {
4950
}
5051
$schemaManager->createTable($table);

src/Crate/DBAL/Driver/PDOCrate/Driver.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Doctrine\DBAL\Connection;
2929
use Doctrine\DBAL\Platforms\AbstractPlatform;
3030
use Doctrine\DBAL\Schema\AbstractSchemaManager;
31+
use SensitiveParameter;
3132

3233
class Driver implements \Doctrine\DBAL\Driver
3334
{
@@ -42,11 +43,12 @@ class Driver implements \Doctrine\DBAL\Driver
4243
* @return PDOConnection The database connection.
4344
*/
4445
public function connect(
45-
array $params,
46-
$username = null,
47-
$password = null,
48-
array $driverOptions = array(),
46+
#[SensitiveParameter]
47+
array $params
4948
): PDOConnection {
49+
$username = $params['user'] ?? null;
50+
$password = $params['password'] ?? null;
51+
$driverOptions = $params['driver_options'] ?? [];
5052
return new PDOConnection($this->constructPdoDsn($params), $username, $password, $driverOptions);
5153
}
5254

src/Crate/DBAL/Platforms/CratePlatform.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ public static function prepareColumnData(AbstractPlatform $platform, $column, $p
795795
$columnData['unique'] = false;
796796
$columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption("version") : false;
797797

798-
if (strtolower($columnData['type']->getName()) == $platform->getVarcharTypeDeclarationSQLSnippet(0, false)
798+
if (strtolower($columnData['type']->getName()) ==
799+
strtolower($platform->getVarcharTypeDeclarationSQLSnippet(0, false))
799800
&& $columnData['length'] === null) {
800801
$columnData['length'] = 255;
801802
}

test/Crate/Test/DBAL/Functional/ConnectionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use Crate\Test\DBAL\DBALFunctionalTestCase;
2525
use Crate\PDO\PDOCrateDB;
26+
use Doctrine\DBAL\DriverManager;
2627

2728
class ConnectionTestCase extends DBALFunctionalTestCase
2829
{
@@ -50,12 +51,11 @@ public function testBasicAuthConnection()
5051
'user' => $auth[0],
5152
'password' => $auth[1],
5253
);
53-
$conn = \Doctrine\DBAL\DriverManager::getConnection($params);
54+
$conn = DriverManager::getConnection($params);
5455
$conn->connect();
5556
$credentials = $conn->getNativeConnection()->getAttribute(PDOCrateDB::CRATE_ATTR_HTTP_BASIC_AUTH);
5657

57-
// No credential leaks any longer: Any empty array is all we got.
58-
$this->assertEquals(array(), $credentials);
58+
$this->assertEquals(array("crate", "secret"), $credentials);
5959
}
6060

6161
public function testGetConnection()

0 commit comments

Comments
 (0)