Skip to content

[5.3] Fix storedAs virtualAs#16683

Merged
taylorotwell merged 1 commit intolaravel:5.3from
fernandobandeira:5.3
Dec 7, 2016
Merged

[5.3] Fix storedAs virtualAs#16683
taylorotwell merged 1 commit intolaravel:5.3from
fernandobandeira:5.3

Conversation

@fernandobandeira
Copy link
Copy Markdown
Contributor

Fixes #16643

Currently the Grammar is appending not null and null when generating the virtualAs and storedAs columns.

This is an invalid syntax since these are generated columns so you can't use that, currently it's throwing:

Syntax error or access violation: 1064 You have an error in your SQL syntax

Example of current sql:

alter table `products` add `price` int not null, add `discounted_virtual` int as (price - 5) not null, add `discounted_stored` int as (price - 5) not null stored

after this fix

alter table `products` add `price` int not null, add `discounted_virtual` int as (price - 5), add `discounted_stored` int as (price - 5) stored

@chuck-wood
Copy link
Copy Markdown

It would be nice to mention this in the documentation. It's just lucky that I happened to notice that my generated columns were lacking their constraints before deploying to production! I am running MySQL, which does support this feature.

I'm on Laravel 5.5, not sure if this has changed in later versions. Thanks!

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