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
JSON defualt value #16107
Comments
This is a MySQL thing :) I guess there are many inconsistencies in the JSON type column, like the integer/float comparison that is type strict unlike the rest of the MySQL fields. However if you have any suggested approaches to deal with the matter please feel free to open a PR. |
|
Oh the joy of little hacks. Here's a simple accessor that solved the issue for me (like @hafezdivandari I too have a
|
u can just do |
Description:
I have
documents
table withparameters
JSON column and a model like this:JSON columns cannot have a default value in Mysql and no update will happen if the value of the column is NULL or empty, so according to this suggestion, I use
stdClass
when create.But It doesn't make sense to set JSON column to
stdClasss
on every single insertion and there should be a way to give it a default value of empty object{}
.I tried to use this mutator to set default value when empty but no chance:
I think Eloquent Model should set an empty object for JSON column types during creation.
Steps To Reproduce:
The text was updated successfully, but these errors were encountered: