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
Fix issues around specifying default values for columns #3318
Conversation
What makes this WIP? |
Some mysql & mssql issue. I added an integration test and it seems like default value for json were failing for them. Checking on it. |
Is the mysql image specified in docker-compose.yml actually used in the tests ? It appears that even though the latest version is specified, the tests are run against some older mysql version. The Build System Information section in Travis logs, show the following:
(which is outdated) Do we want to support older versions of mysql (which didn't support default values for json columns) ? From MySQL docs:
|
@lorefnon Hmmm, good question, I wonder where else it could come from. |
I would say that since we made a switch to run tests on MySQL 8, it would make sense to run them on latest one. As long as older versions are still supposed to work when not using the new functionality, we should be good. |
Im pretty sure that docker version is used. The one coming from travis is the old one. Docker version is running in different port. |
I think using latest version is better than fixing version to 8 |
Yes, I have verified that now. Something else is wrong. I'll remove the second commit before removing WIP. I fixed the version just to be sure. |
Sorry about the spam about incorrect version. The problem was that mysql allows default values for json, only when they are expressions. So json string literals need to be wrapped in parenthesis. |
Would be cool to also have an integration test which would verify that defaults actually kick in when inserting new rows. |
new test seems to be failing in pg, mysql and mssql. |
Is it expected that in dialects other than postgres, json columns are returned as string ? I initially thought something was wrong with how default value was getting populated but it seems unrelated:
In postgres though querying json column returns javascript objects, which imho is the ideal thing to do. |
@lorefnon I think this is leftover from the times where those databases didn't support proper JSON columns so we were storing them as strings. I agree that javascript objects make more sense, but that would be a breaking change; probaably we can do it in 0.19.0 after 0.18 branch quiets down a bit. |
…igned for text & blob columns, both of which work fine
This is fixed now. |
This PR addresses following issues:
SQL Server allows default values for BLOB/nvarchar but knex ignores defaults for these types. This PR removes that behavior.
Setting default value of JSON(B) fields don't work and results in invalid syntax for pretty much all dialects (unless knex.raw is explicitly used).