Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
remove doctrine dbal from grammar
  • Loading branch information
hafezdivandari committed Nov 6, 2023
commit f6538ad9bb87c36f3b0252668ec7cb25f8873291
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"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).",
"doctrine/dbal": "Required to modify SQLite columns (^4.0).",
"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
14 changes: 0 additions & 14 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1226,20 +1226,6 @@ 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.
*
Expand Down
7 changes: 0 additions & 7 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ public function toSql(Connection $connection, Grammar $grammar)
protected function ensureCommandsAreValid(Connection $connection)
{
if ($connection instanceof SQLiteConnection) {
if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1
&& ! $connection->usingNativeSchemaOperations()) {
throw new BadMethodCallException(
"SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
);
}

if ($this->commandsNamed(['dropForeign'])->count() > 0) {
throw new BadMethodCallException(
"SQLite doesn't support dropping foreign keys (you would need to re-create the table)."
Expand Down
8 changes: 0 additions & 8 deletions src/Illuminate/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ public function whenTableDoesntHaveColumn(string $table, string $column, Closure
*/
public function getColumnType($table, $column, $fullDefinition = false)
{
$table = $this->connection->getTablePrefix().$table;

if (! $this->connection->usingNativeSchemaOperations()) {
$type = $this->connection->getDoctrineColumn($table, $column)->getType();

return $type::lookupName($type);
}

$columns = $this->getColumns($table);

foreach ($columns as $value) {
Expand Down
24 changes: 5 additions & 19 deletions src/Illuminate/Database/Schema/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Illuminate\Database\Schema\Grammars;

use BackedEnum;
use Doctrine\DBAL\Schema\AbstractSchemaManager as SchemaManager;
use Doctrine\DBAL\Schema\TableDiff;
use Illuminate\Contracts\Database\Query\Expression;
use Illuminate\Database\Concerns\CompilesJsonPaths;
use Illuminate\Database\Connection;
Expand Down Expand Up @@ -76,7 +74,11 @@ public function compileDropDatabaseIfExists($name)
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return RenameColumn::compile($this, $blueprint, $command, $connection);
return sprintf('alter table %s rename column %s to %s',
$this->wrapTable($blueprint),
$this->wrap($command->from),
$this->wrap($command->to)
);
}

/**
Expand Down Expand Up @@ -319,22 +321,6 @@ protected function getDefaultValue($value)
: "'".(string) $value."'";
}

/**
* Create an empty Doctrine DBAL TableDiff from the Blueprint.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @return \Doctrine\DBAL\Schema\TableDiff
*/
public function getDoctrineTableDiff(Blueprint $blueprint, SchemaManager $schema)
{
$tableName = $this->getTablePrefix().$blueprint->getTable();

$table = $schema->introspectTable($tableName);

return $schema->createComparator()->compareTables(oldTable: $table, newTable: $table);
}

/**
* Get the fluent commands for the grammar.
*
Expand Down
19 changes: 0 additions & 19 deletions src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,25 +230,6 @@ public function compileAutoIncrementStartingValues(Blueprint $blueprint, Fluent
}
}

/**
* Compile a rename column command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @param \Illuminate\Database\Connection $connection
* @return array|string
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return $connection->usingNativeSchemaOperations()
? sprintf('alter table %s rename column %s to %s',
$this->wrapTable($blueprint),
$this->wrap($command->from),
$this->wrap($command->to)
)
: parent::compileRenameColumn($blueprint, $command, $connection);
}

/**
* Compile a change column command into a series of SQL statements.
*
Expand Down
19 changes: 0 additions & 19 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,6 @@ public function compileAutoIncrementStartingValues(Blueprint $blueprint, Fluent
}
}

/**
* Compile a rename column command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @param \Illuminate\Database\Connection $connection
* @return array|string
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return $connection->usingNativeSchemaOperations()
? sprintf('alter table %s rename column %s to %s',
$this->wrapTable($blueprint),
$this->wrap($command->from),
$this->wrap($command->to)
)
: parent::compileRenameColumn($blueprint, $command, $connection);
}

/**
* Compile a change column command into a series of SQL statements.
*
Expand Down
93 changes: 0 additions & 93 deletions src/Illuminate/Database/Schema/Grammars/RenameColumn.php

This file was deleted.

60 changes: 3 additions & 57 deletions src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Database\Schema\Grammars;

use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
Expand Down Expand Up @@ -163,25 +162,6 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
})->all();
}

/**
* Compile a rename column command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @param \Illuminate\Database\Connection $connection
* @return array|string
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return $connection->usingNativeSchemaOperations()
? sprintf('alter table %s rename column %s to %s',
$this->wrapTable($blueprint),
$this->wrap($command->from),
$this->wrap($command->to)
)
: parent::compileRenameColumn($blueprint, $command, $connection);
}

/**
* Compile a unique key command.
*
Expand Down Expand Up @@ -324,45 +304,11 @@ public function compileRebuild()
*/
public function compileDropColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
if ($connection->usingNativeSchemaOperations()) {
$table = $this->wrapTable($blueprint);

$columns = $this->prefixArray('drop column', $this->wrapArray($command->columns));

return collect($columns)->map(fn ($column) => 'alter table '.$table.' '.$column
)->all();
} else {
$tableDiff = $this->getDoctrineTableDiff(
$blueprint, $schema = $connection->getDoctrineSchemaManager()
);
$table = $this->wrapTable($blueprint);

$droppedColumns = [];
$columns = $this->prefixArray('drop column', $this->wrapArray($command->columns));

foreach ($command->columns as $name) {
$droppedColumns[$name] = $connection->getDoctrineColumn(
$this->getTablePrefix().$blueprint->getTable(), $name
);
}

$platform = $connection->getDoctrineConnection()->getDatabasePlatform();

return (array) $platform->getAlterTableSQL(
new TableDiff(
$tableDiff->getOldTable(),
$tableDiff->getAddedColumns(),
$tableDiff->getModifiedColumns(),
$droppedColumns,
$tableDiff->getRenamedColumns(),
$tableDiff->getAddedIndexes(),
$tableDiff->getModifiedIndexes(),
$tableDiff->getDroppedIndexes(),
$tableDiff->getRenamedIndexes(),
$tableDiff->getAddedForeignKeys(),
$tableDiff->getModifiedColumns(),
$tableDiff->getDroppedForeignKeys(),
)
);
}
return collect($columns)->map(fn ($column) => 'alter table '.$table.' '.$column)->all();
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return $connection->usingNativeSchemaOperations()
? sprintf("sp_rename '%s', %s, 'COLUMN'",
$this->wrap($blueprint->getTable().'.'.$command->from),
$this->wrap($command->to)
)
: parent::compileRenameColumn($blueprint, $command, $connection);
return sprintf("sp_rename '%s', %s, 'COLUMN'",
$this->wrap($blueprint->getTable().'.'.$command->from),
$this->wrap($command->to)
);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/Database/DatabaseSchemaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Processors\Processor;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Schema\Grammars\Grammar;
use LogicException;
Expand Down Expand Up @@ -73,16 +74,15 @@ public function testTableHasColumns()
public function testGetColumnTypeAddsPrefix()
{
$connection = m::mock(Connection::class);
$column = m::mock(Column::class);
$type = m::mock(Type::class);
$grammar = m::mock(Grammar::class);
$processor = m::mock(Processor::class);
$connection->shouldReceive('getSchemaGrammar')->once()->andReturn($grammar);
$connection->shouldReceive('getPostProcessor')->andReturn($processor);
$processor->shouldReceive('processColumns')->once()->andReturn([['name' => 'id', 'type_name' => 'integer']]);
$builder = new Builder($connection);
$connection->shouldReceive('getTablePrefix')->once()->andReturn('prefix_');
$connection->shouldReceive('getDoctrineColumn')->once()->with('prefix_users', 'id')->andReturn($column);
$connection->shouldReceive('usingNativeSchemaOperations')->once()->andReturn(false);
$column->shouldReceive('getType')->once()->andReturn($type);
$type->shouldReceive('lookupName')->once()->andReturn('integer');
$grammar->shouldReceive('compileColumns')->once()->with('prefix_users')->andReturn('sql');
$connection->shouldReceive('selectFromWriteConnection')->once()->with('sql')->andReturn([['name' => 'id', 'type_name' => 'integer']]);

$this->assertSame('integer', $builder->getColumnType('users', 'id'));
}
Expand Down
Loading