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

Correct typing for startedAs and virtualAs database column definitions #50851

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

ollieread
Copy link
Contributor

This PR changes the typing of ColumnDefinition::storedAs() and ColumnDefinition::virtualAs() to include \Illuminate\Database\Query\Expression and not just string.

This has been done because ColumnDefinition::generatedAs() accepts the type string|\Illuminate\Database\Query\Expression, and after digging through the code that creates the columns, all three types are capable of handling expressions.

This is QOL PR that just makes Laravels typing a bit nicer to work with.

@crynobone
Copy link
Member

crynobone commented Mar 31, 2024

Any specific reason we type-hinting to implementation Illuminate\Database\Query\Expression instead of the interface Illuminate\Contracts\Database\Query\Expression?

@ollieread
Copy link
Contributor Author

Any specific reason we type-hinting to implementation Illuminate\Database\Query\Expression instead of the interface Illuminate\Contracts\Database\Query\Expression?

That's the value used by generatedAs(), which I suspect is a layover from when we didn't have the contract. I'll update.

@ollieread ollieread force-pushed the column-definition-expressions branch from 4bba113 to e2e7e54 Compare March 31, 2024 11:31
@taylorotwell taylorotwell merged commit 175b0bb into laravel:11.x Apr 1, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants