Closed YaleChen299 closed 11 months ago
One of the migration files was in the wrong format (and thus skipped) but somehow the test cases still passed... Let's look into it before merging.
I looked into it... the tests still passed because we enforce a non-null constraint in the model layer (because it's typed
uint
not*uint
). So regardless of whether or not the DB has a non-null constraint, inserting empty will fail due to 0 being an FK violation.Even with the migration file fixed, the insert fails not because of the null constraint violation, but instead because of the FK violation (inserting 0).
I think we should use
db.Exec
ordb.Raw
instead of relying on the model to test. That way, we can test for both behaviors: null constraint violation as well as FK violation.Thoughts? @YaleChen299
Yup I agree. I will do it. I will do it
coverage: 52.245% (+0.4%) from 51.837% when pulling 224ffc7a7343f85ca79b90f8b1c2227300ad078d on add-author-fk-non-null into f10dabed4ba5901c1becbd381e383d3a16fc9597 on main.