Skip to content

Commit 9ccf003

Browse files
[11.x] Remove Doctrine DBAL (#48864)
* remove doctrine dbal from grammar * remove unused imports * fix tests * fix tests * remove mysql 5.7 tests * fix facade doctype * use native column modifying by default * fix tests * fix tests * wip * Revert "remove mysql 5.7 tests" This reverts commit ba31106. * support native column renaming on MySQL 5.7 * fix style * wip * wip * remove doctrine usage on DatabaseTruncation * wip * rename index on sqlite * remove doctrine/dbal from db commands * fix styles * wip * wip * support renaming columns on legacy MariaDB * remove redundant non-standard tests * add collation modifier to sqlite * support native column modifying on sqlite * fix styles * add user-defined types to db:show * wip * fix styles * fix dropForeign exception on SQLite * fix styles * include generated and hidden columns on sqlite * remove custom doctrine types * remove doctrine change column * styling * remove support for registering custom doctrine types * remove unused config methods and property * remove redundant semicolon * force re-run tests * remove doctrine related conflicts reverts #49438 and #49456 * remove doctrine/dbal from require-dev * Revert "remove doctrine/dbal from require-dev" This reverts commit fc4dd91. * revert unrelated changes * disable foreign key constraints when altering table on SQLite * fix styling * consider backticks when parsing collate on SQLite * update facade docblocks * remove doctrine connection * formatting * fix conflicts * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 0ca166c commit 9ccf003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+651
-2101
lines changed

composer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"ext-gmp": "*",
9797
"ably/ably-php": "^1.0",
9898
"aws/aws-sdk-php": "^3.235.5",
99-
"doctrine/dbal": "^4.0",
10099
"fakerphp/faker": "^1.23",
101100
"guzzlehttp/guzzle": "^7.8",
102101
"league/flysystem-aws-s3-v3": "^3.0",
@@ -120,8 +119,6 @@
120119
"psr/simple-cache-implementation": "1.0|2.0|3.0"
121120
},
122121
"conflict": {
123-
"carbonphp/carbon-doctrine-types": "<3.0.0|>=4.0",
124-
"doctrine/dbal": "<4.0.0|>=5.0",
125122
"tightenco/collect": "<5.5.33"
126123
},
127124
"autoload": {
@@ -167,7 +164,6 @@
167164
"ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
168165
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).",
169166
"brianium/paratest": "Required to run tests in parallel (^6.0).",
170-
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^4.0).",
171167
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
172168
"filp/whoops": "Required for friendly error pages in development (^2.14.3).",
173169
"guzzlehttp/guzzle": "Required to use the HTTP Client and the ping methods on schedules (^7.8).",

src/Illuminate/Database/Connection.php

Lines changed: 10 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use Carbon\CarbonInterval;
66
use Closure;
77
use DateTimeInterface;
8-
use Doctrine\DBAL\Connection as DoctrineConnection;
9-
use Doctrine\DBAL\Types\Type;
108
use Exception;
119
use Illuminate\Contracts\Events\Dispatcher;
1210
use Illuminate\Database\Events\QueryExecuted;
@@ -189,20 +187,6 @@ class Connection implements ConnectionInterface
189187
*/
190188
protected $beforeExecutingCallbacks = [];
191189

192-
/**
193-
* The instance of Doctrine connection.
194-
*
195-
* @var \Doctrine\DBAL\Connection
196-
*/
197-
protected $doctrineConnection;
198-
199-
/**
200-
* Type mappings that should be registered with new Doctrine connections.
201-
*
202-
* @var array<string, string>
203-
*/
204-
protected $doctrineTypeMappings = [];
205-
206190
/**
207191
* The connection resolvers.
208192
*
@@ -989,8 +973,6 @@ protected function tryAgainIfCausedByLostConnection(QueryException $e, $query, $
989973
public function reconnect()
990974
{
991975
if (is_callable($this->reconnector)) {
992-
$this->doctrineConnection = null;
993-
994976
return call_user_func($this->reconnector, $this);
995977
}
996978

@@ -1017,8 +999,6 @@ public function reconnectIfMissingConnection()
1017999
public function disconnect()
10181000
{
10191001
$this->setPdo(null)->setReadPdo(null);
1020-
1021-
$this->doctrineConnection = null;
10221002
}
10231003

10241004
/**
@@ -1208,106 +1188,6 @@ public function useWriteConnectionWhenReading($value = true)
12081188
return $this;
12091189
}
12101190

1211-
/**
1212-
* Is Doctrine available?
1213-
*
1214-
* @return bool
1215-
*/
1216-
public function isDoctrineAvailable()
1217-
{
1218-
return class_exists('Doctrine\DBAL\Connection');
1219-
}
1220-
1221-
/**
1222-
* Indicates whether native alter operations will be used when dropping, renaming, or modifying columns, even if Doctrine DBAL is installed.
1223-
*
1224-
* @return bool
1225-
*/
1226-
public function usingNativeSchemaOperations()
1227-
{
1228-
return ! $this->isDoctrineAvailable() || SchemaBuilder::$alwaysUsesNativeSchemaOperationsIfPossible;
1229-
}
1230-
1231-
/**
1232-
* Get a Doctrine Schema Column instance.
1233-
*
1234-
* @param string $table
1235-
* @param string $column
1236-
* @return \Doctrine\DBAL\Schema\Column
1237-
*/
1238-
public function getDoctrineColumn($table, $column)
1239-
{
1240-
$schema = $this->getDoctrineSchemaManager();
1241-
1242-
return $schema->introspectTable($table)->getColumn($column);
1243-
}
1244-
1245-
/**
1246-
* Get the Doctrine DBAL schema manager for the connection.
1247-
*
1248-
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
1249-
*/
1250-
public function getDoctrineSchemaManager()
1251-
{
1252-
$connection = $this->getDoctrineConnection();
1253-
1254-
return $connection->createSchemaManager();
1255-
}
1256-
1257-
/**
1258-
* Get the Doctrine DBAL database connection instance.
1259-
*
1260-
* @return \Doctrine\DBAL\Connection
1261-
*/
1262-
public function getDoctrineConnection()
1263-
{
1264-
if (is_null($this->doctrineConnection)) {
1265-
$driver = $this->getDoctrineDriver();
1266-
1267-
$this->doctrineConnection = new DoctrineConnection(array_filter([
1268-
'pdo' => $this->getPdo(),
1269-
'dbname' => $this->getDatabaseName(),
1270-
'driver' => $driver->getName(),
1271-
'serverVersion' => $this->getConfig('server_version'),
1272-
]), $driver);
1273-
1274-
foreach ($this->doctrineTypeMappings as $name => $type) {
1275-
$this->doctrineConnection
1276-
->getDatabasePlatform()
1277-
->registerDoctrineTypeMapping($type, $name);
1278-
}
1279-
}
1280-
1281-
return $this->doctrineConnection;
1282-
}
1283-
1284-
/**
1285-
* Register a custom Doctrine mapping type.
1286-
*
1287-
* @param Type|class-string<Type> $class
1288-
* @param string $name
1289-
* @param string $type
1290-
* @return void
1291-
*
1292-
* @throws \Doctrine\DBAL\Exception
1293-
* @throws \RuntimeException
1294-
*/
1295-
public function registerDoctrineType(Type|string $class, string $name, string $type): void
1296-
{
1297-
if (! $this->isDoctrineAvailable()) {
1298-
throw new RuntimeException(
1299-
'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
1300-
);
1301-
}
1302-
1303-
if (! Type::hasType($name)) {
1304-
Type::getTypeRegistry()
1305-
->register($name, is_string($class) ? new $class() : $class);
1306-
}
1307-
1308-
$this->doctrineTypeMappings[$name] = $type;
1309-
}
1310-
13111191
/**
13121192
* Get the current PDO connection.
13131193
*
@@ -1722,6 +1602,16 @@ public function withTablePrefix(Grammar $grammar)
17221602
return $grammar;
17231603
}
17241604

1605+
/**
1606+
* Get the server version for the connection.
1607+
*
1608+
* @return string
1609+
*/
1610+
public function getServerVersion(): string
1611+
{
1612+
return $this->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
1613+
}
1614+
17251615
/**
17261616
* Register a connection resolver.
17271617
*

0 commit comments

Comments
 (0)