-
Notifications
You must be signed in to change notification settings - Fork 297
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
Support declaring Maybe before the type in model definitions #1264
Support declaring Maybe before the type in model definitions #1264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's write a test in persistent-test
that'll be run on the various backends and ensure that migrations are getting handled correctly.
I expect that they are, but it's good to double check :)
persistent/Database/Persist/Quasi.hs
Outdated
> nullableField Int nullable | ||
|
||
However the difference here is in the first instance the Haskell type will be 'Maybe Int', | ||
but in the second it will be 'Int'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a note that this will cause runtime errors if the database returns NULL
and the PersistField
instance for the type in question doesn't handle PersistNull
.
> TableName | ||
> fieldName FieldType | ||
> otherField String | ||
> nullableField (Maybe Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
@@ -176,6 +178,7 @@ spec = describe "THSpec" $ do | |||
SharedPrimaryKeySpec.spec | |||
SharedPrimaryKeyImportedSpec.spec | |||
ImplicitIdColSpec.spec | |||
MaybeFieldDefsSpec.spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay awesome
This is testing that the TH generation does the right thing for the Haskell side
CI is fixed on master |
8414bc5
to
3de32af
Compare
36a8a11
to
9fac010
Compare
9fac010
to
b6a9c9b
Compare
Ah, now we're failing because of MongoDB. I'm going to merge this into a branch and finish it. Thanks so much, and sorry it took me so long to review! |
* Support declaring Maybe before the type in model definitions (#1264) * Add missing type sigs * Extract/dry up is nullable * Extract/rename associateComments function * Implement a way of detecting Maybe field defs * Fixing warnings * Add a spec * Add documentation * Add PR reference to changelog * Add a test to cover the various backends * Also test mongo * Fix test compilation issues * Update readme Co-authored-by: Matt Parsons <parsonsmatt@gmail.com> * gotta fix that Co-authored-by: Dan Brooks <danbroooks@users.noreply.github.com>
Before submitting your PR, check that you've:
@since
declarations to the Haddockstylish-haskell
on any changed files..editorconfig
file for details)After submitting your PR:
(unreleased)
on the ChangelogCloses #277