Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Remove Doctrine DBAL #48864

Merged
merged 61 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f6538ad
remove doctrine dbal from grammar
hafezdivandari Oct 31, 2023
8d882eb
remove unused imports
hafezdivandari Oct 31, 2023
c37884d
fix tests
hafezdivandari Oct 31, 2023
0346940
fix tests
hafezdivandari Oct 31, 2023
ba31106
remove mysql 5.7 tests
hafezdivandari Oct 31, 2023
ca78589
fix facade doctype
hafezdivandari Oct 31, 2023
f55b31e
use native column modifying by default
hafezdivandari Oct 31, 2023
90d1f8a
fix tests
hafezdivandari Oct 31, 2023
a5f4957
Merge branch 'master' into master-patch-2
hafezdivandari Nov 8, 2023
8c39f63
fix tests
hafezdivandari Nov 8, 2023
45310fd
wip
hafezdivandari Nov 8, 2023
19d5f92
Revert "remove mysql 5.7 tests"
hafezdivandari Nov 21, 2023
61208ea
support native column renaming on MySQL 5.7
hafezdivandari Nov 21, 2023
41837ca
fix style
hafezdivandari Nov 21, 2023
f612a13
wip
hafezdivandari Nov 21, 2023
019a868
Merge branch 'master' into master-patch-2
hafezdivandari Nov 28, 2023
fc2f9af
wip
hafezdivandari Nov 28, 2023
274fe12
remove doctrine usage on DatabaseTruncation
hafezdivandari Nov 28, 2023
a30d550
Merge branch 'master' into master-patch-2
hafezdivandari Dec 10, 2023
73754a4
wip
hafezdivandari Dec 10, 2023
f082214
rename index on sqlite
hafezdivandari Dec 10, 2023
254e099
remove doctrine/dbal from db commands
hafezdivandari Dec 10, 2023
49a0c3f
fix styles
hafezdivandari Dec 10, 2023
ba0d8ea
wip
hafezdivandari Dec 10, 2023
bd1bceb
wip
hafezdivandari Dec 11, 2023
ba4978e
support renaming columns on legacy MariaDB
hafezdivandari Dec 11, 2023
eae02d9
remove redundant non-standard tests
hafezdivandari Dec 11, 2023
a99792e
Merge branch 'master' into master-patch-2
hafezdivandari Dec 13, 2023
b5c3862
Merge branch 'master' into master-patch-2
hafezdivandari Dec 16, 2023
92d0ec9
add collation modifier to sqlite
hafezdivandari Dec 17, 2023
8b6c226
support native column modifying on sqlite
hafezdivandari Dec 17, 2023
402830d
fix styles
hafezdivandari Dec 17, 2023
9a7be0c
add user-defined types to db:show
hafezdivandari Dec 17, 2023
686ec27
wip
hafezdivandari Dec 17, 2023
d44e2c6
fix styles
hafezdivandari Dec 17, 2023
ebd9bee
fix dropForeign exception on SQLite
hafezdivandari Dec 17, 2023
46562fb
fix styles
hafezdivandari Dec 17, 2023
1cc64af
include generated and hidden columns on sqlite
hafezdivandari Dec 18, 2023
1d8510f
remove custom doctrine types
hafezdivandari Dec 18, 2023
86058a8
remove doctrine change column
hafezdivandari Dec 18, 2023
88c2752
styling
hafezdivandari Dec 18, 2023
298b43f
remove support for registering custom doctrine types
hafezdivandari Dec 18, 2023
b60b221
remove unused config methods and property
hafezdivandari Dec 18, 2023
35666b3
remove redundant semicolon
hafezdivandari Dec 19, 2023
8102add
Merge branch 'master' into master-patch-2
hafezdivandari Dec 21, 2023
3a8acd2
force re-run tests
hafezdivandari Dec 21, 2023
29cfb81
remove doctrine related conflicts
hafezdivandari Dec 22, 2023
fc4dd91
remove doctrine/dbal from require-dev
hafezdivandari Dec 22, 2023
fa197e0
Revert "remove doctrine/dbal from require-dev"
hafezdivandari Dec 22, 2023
2fb96c4
revert unrelated changes
hafezdivandari Dec 25, 2023
d7e1ddf
disable foreign key constraints when altering table on SQLite
hafezdivandari Dec 25, 2023
0aa3207
fix styling
hafezdivandari Dec 25, 2023
606663d
consider backticks when parsing collate on SQLite
hafezdivandari Dec 25, 2023
02eef27
update facade docblocks
hafezdivandari Dec 27, 2023
5e99d96
remove doctrine connection
hafezdivandari Dec 27, 2023
20f80bb
Merge branch 'master' into master-patch-2
hafezdivandari Jan 3, 2024
7110c42
formatting
hafezdivandari Jan 3, 2024
b88f803
Merge branch 'master' into master-patch-2
hafezdivandari Jan 5, 2024
f5a2c8a
Merge branch 'master' into master-patch-2
hafezdivandari Jan 9, 2024
055e1cd
fix conflicts
hafezdivandari Jan 9, 2024
63ea4d6
formatting
taylorotwell Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@
"psr/simple-cache-implementation": "1.0|2.0|3.0"
},
"conflict": {
"carbonphp/carbon-doctrine-types": "<3.0.0|>=4.0",
"doctrine/dbal": "<4.0.0|>=5.0",
"tightenco/collect": "<5.5.33"
},
"autoload": {
Expand Down Expand Up @@ -167,7 +165,6 @@
"ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).",
"brianium/paratest": "Required to run tests in parallel (^6.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^4.0).",
crynobone marked this conversation as resolved.
Show resolved Hide resolved
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"filp/whoops": "Required for friendly error pages in development (^2.14.3).",
"guzzlehttp/guzzle": "Required to use the HTTP Client and the ping methods on schedules (^7.6).",
Expand Down
97 changes: 10 additions & 87 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Closure;
use DateTimeInterface;
use Doctrine\DBAL\Connection as DoctrineConnection;
use Doctrine\DBAL\Types\Type;
use Exception;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Events\QueryExecuted;
Expand Down Expand Up @@ -196,13 +195,6 @@ class Connection implements ConnectionInterface
*/
protected $doctrineConnection;

/**
* Type mappings that should be registered with new Doctrine connections.
*
* @var array<string, string>
*/
protected $doctrineTypeMappings = [];

/**
* The connection resolvers.
*
Expand Down Expand Up @@ -1208,52 +1200,6 @@ public function useWriteConnectionWhenReading($value = true)
return $this;
}

/**
* Is Doctrine available?
*
* @return bool
*/
public function isDoctrineAvailable()
{
return class_exists('Doctrine\DBAL\Connection');
}

/**
* Indicates whether native alter operations will be used when dropping, renaming, or modifying columns, even if Doctrine DBAL is installed.
*
* @return bool
*/
public function usingNativeSchemaOperations()
{
return ! $this->isDoctrineAvailable() || SchemaBuilder::$alwaysUsesNativeSchemaOperationsIfPossible;
}

/**
* Get a Doctrine Schema Column instance.
*
* @param string $table
* @param string $column
* @return \Doctrine\DBAL\Schema\Column
*/
public function getDoctrineColumn($table, $column)
{
$schema = $this->getDoctrineSchemaManager();

return $schema->introspectTable($table)->getColumn($column);
}

/**
* Get the Doctrine DBAL schema manager for the connection.
*
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
*/
public function getDoctrineSchemaManager()
{
$connection = $this->getDoctrineConnection();

return $connection->createSchemaManager();
}

/**
* Get the Doctrine DBAL database connection instance.
*
Expand All @@ -1270,44 +1216,11 @@ public function getDoctrineConnection()
'driver' => $driver->getName(),
'serverVersion' => $this->getConfig('server_version'),
]), $driver);

foreach ($this->doctrineTypeMappings as $name => $type) {
$this->doctrineConnection
->getDatabasePlatform()
->registerDoctrineTypeMapping($type, $name);
}
}

return $this->doctrineConnection;
}

/**
* Register a custom Doctrine mapping type.
*
* @param Type|class-string<Type> $class
* @param string $name
* @param string $type
* @return void
*
* @throws \Doctrine\DBAL\Exception
* @throws \RuntimeException
*/
public function registerDoctrineType(Type|string $class, string $name, string $type): void
{
if (! $this->isDoctrineAvailable()) {
throw new RuntimeException(
'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
);
}

if (! Type::hasType($name)) {
Type::getTypeRegistry()
->register($name, is_string($class) ? new $class() : $class);
}

$this->doctrineTypeMappings[$name] = $type;
}

/**
* Get the current PDO connection.
*
Expand Down Expand Up @@ -1722,6 +1635,16 @@ public function withTablePrefix(Grammar $grammar)
return $grammar;
}

/**
* Get the server version for the connection.
*
* @return string
*/
public function getServerVersion(): string
{
return $this->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
}

/**
* Register a connection resolver.
*
Expand Down
Loading