Column default seems to be a problem in 0.24
Upgraded to Lucky 0.24 on kindmetrics today.
I got issues that a boolean was required after the upgrade, making my tests to fail after the upgrade.
I localized the issue to a column that is Boolean which seems to not have a default value.
column is_accepted : Bool
If I do:
column is_accepted : Bool = false
it works fine.
The error I got in the API was:
{"message":"Invalid params","param":"is_accepted","details":"is_accepted is required"}
I might have done something wrong in the migration or similar. But then it is even weirder than it is complaining after the upgrade of all times, or is it any changes to the validations that might make this to come up now?
My guess is it's related to this https://github.com/luckyframework/avram/pull/461 which will be fixed in the next release. But you can also take a look at https://github.com/luckyframework/avram/pull/424 in case you see I may have missed something? The main idea is that if your migration sets a default value for a column, then there should be that same default value set in your model.
@jwoertink, this seems not to be connected to luckyframework/avram#461 - maybe it is luckyframework/avram#424 - I will explain more below so you can check and be sure.
This is the test that was failing: https://github.com/kindmetrics/kindmetrics/blob/master/spec/requests/api/domains/create_spec.cr
It complained about the admin boolean in the user model on that test. In the savedomain operation, it calls SaveUser to update the current domain for that user. Which probably is the thing that triggers this error.
But I don't have any required on admin on the saveUser operation. So it could be something else that triggers this issue.
If you get a chance, can you add a shard.override.yml file with:
dependencies:
avram:
github: luckyframework/avram
branch: master
And see if it still does it?
@jwoertink still get that error.
I added the override file, ran shards, and removed = false on admin and tested that spec test again.
here is the response body:
@body=
"{\"message\":\"Invalid params\",\"param\":\"admin\",\"details\":\"admin is required\"}",
Ok, thanks for checking. I was hoping that would have fixed it, but no worries. We will dig in and figure out what's up!
@jwoertink could this be connected to https://github.com/luckyframework/lucky/issues/1351 ? As param is used to set the column? could maybe @matthewmcgarvey confirm?
I'm not sure, but we can get it merged in to get testing it and see!
I'm pretty sure this is fixed now. I tried upgrading Kindmetrics, but it required clickhouse to be booted in order to run the specs, and I didn't want to install that. :zany_face: If anyone else runs in to a similar issue, we can reopen this.