Conversation
|
Weird, I am getting test suite failures locally for MongoDB: The IDs are different. I did not get these earlier when I was refactoring the test suite, and they don't appear to show up in CI? |
| $ "Generating Persistent entities now requires the 'UndecidableInstances' " | ||
| <> "language extension. Please enable it in your file by copy/pasting " | ||
| <> "this line into the top of your file: \n\n" | ||
| <> "{-# LANGUAGE UndecidableInstances #-}" |
There was a problem hiding this comment.
This gives a pretty pleasant error message. The alternative is a bit nasty.
|
|
||
| singleUniqueKey :: Q [Dec] | ||
| singleUniqueKey = do | ||
| expr <- [e|\p -> head (persistUniqueKeysP p)|] |
There was a problem hiding this comment.
this is safe because we have already guaranteed that there are multiple unique keys
| pBlue30 <- updateGet key25 [PersonAge +=. 2] | ||
| pBlue30 @== Person "Updated" 30 Nothing | ||
|
|
||
| describe "putMany" $ do |
There was a problem hiding this comment.
These specs are failing for MongoDB locally for me. The keys are changing, so it isn't updating, but replacing. Strange! I moved them into upsert specs which is pending for now.
|
|
||
| singleUniqueKey :: Q [Dec] | ||
| singleUniqueKey = do | ||
| expr <- [e|\p -> head (persistUniqueKeys p)|] |
There was a problem hiding this comment.
this is "safe" because the generating code has already guaranteed that we have exactly one unique key.
|
|
||
| atLeastOneKey :: Q [Dec] | ||
| atLeastOneKey = do | ||
| expr <- [e|\p -> NEL.fromList (persistUniqueKeys p)|] |
There was a problem hiding this comment.
likewise, this is safe because we have a guarantee from the generating code that it has at least one key.
| @@ -1,5 +1,6 @@ | |||
| {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-orphans -O0 #-} | |||
| {-# LANGUAGE DeriveDataTypeable #-} | |||
| {-# LANGUAGE UndecidableInstances #-} | |||
There was a problem hiding this comment.
This change requires UndecidableInstances. I give a nice error message for upgrading.
| Don'tUpdateNull -> | ||
| Nothing | ||
|
|
||
| describe "putMany" $ do |
There was a problem hiding this comment.
Moved from the PersistentTest module so that mongoDB could skip them for now.
| -- * If the record exists (matched via it's uniqueness constraint), then update the existing record with the parameters which is passed on as list to the function. | ||
| -- | ||
| -- Throws an exception if there is more than 1 uniqueness constraint. | ||
| -- |
|
Do we need to bump the major versions of the component libraries? eg |
|
Ah, dang. We can't do |
This PR introduces a few type classes that are required on
upsertand related functions that have expectations on how many unique keys a record has.Instances for these classes are generated automatically, and "failing" instances get informative "TypeError"s when you misuse them.
Fixes #868
Fixes #796
Before submitting your PR, check that you've:
@sincedeclarations to the HaddockAfter submitting your PR: