[10.x] Get columns of a table#48357
Merged
taylorotwell merged 7 commits intolaravel:10.xfrom Oct 26, 2023
Merged
Conversation
Contributor
|
@hafezdivandari I am curious about the third point if I haven't add Am i missing something here? |
Contributor
Author
|
@morloderex These are separated matters, you have to call
|
30 tasks
This was referenced Dec 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous attempt (PR #45598) was a breaking change and tabled a few days before Laravel 10 release. This PR has more features than the previous one and is not a breaking change.
Usage
Schema::getColumns()name(string): Name of the columntype_name(string): Type nametype(string): Full definition of the column typecollation(?string): Collation of the columnnullable(boolean): Is column nullable?default(?string): Default expression of the column if definedauto_increment(boolean): Does column auto increment?comment(?string): Comment of the column if existsgeneration(null|array) (added on Laravel 11 via [11.x] Add support for modifying generated columns #50329):type(string): Generation type:'stored'or'virtual'.expression(string): Generation expression.Changes
This PR:
Adds a new
Schema::getColumns():Currently, we are using
doctrine/dbalto get columns of a table and their attributes, for example onmodel:showartisan command. This PR addsSchema::getColumns($table)for MySQL, PostgreSQL, SQLite and SQL Server without Doctrine DBAL type mapping issues and full support for all native types. This function returns a list of columns and their attributes:Adds native support for
Schema::getColumnType():Currently we are using Doctrine DBAL to get column type using
Schema::getColumnTypemethod. DBAL maps every native column type to its Doctrine type equivalent and doesn't support many column types used by Laravel on different databases.After this PR you won't need to install
doctrine/dbalto get type of a column, you'll be able to get eighter data type name or full type definition of the given column:Just like [10.x] Add support for native column modifying #45487, if you have already installed
doctrine/dbal, you have to callSchema::useNativeSchemaOperationsIfPossible()method within thebootmethod of yourApp\Providers\AppServiceProviderclass to be able to use native schema operations.Deprecates a few functions:
This PR makes
Schema::getColumnListing()function to use newly addedSchema::getColumns()method under the hood, so we don't need any of the following functions any more. This PR deprecates:\Illuminate\Database\Query\Processors\Processor::processColumnListing\Illuminate\Database\Query\Processors\MySqlProcessor::processColumnListing\Illuminate\Database\Query\Processors\PostgresProcessor::processColumnListing\Illuminate\Database\Query\Processors\SQLiteProcessor::processColumnListing\Illuminate\Database\Query\Processors\SqlServerProcessor::processColumnListing\Illuminate\Database\Schema\Grammars\MySqlGrammar::compileColumnListing\Illuminate\Database\Schema\Grammars\PostgresGrammar::compileColumnListing\Illuminate\Database\Schema\Grammars\SQLiteGrammar::compileColumnListing\Illuminate\Database\Schema\Grammars\SqlServerGrammar::compileColumnListing