yesodweb / yesodweb/persistent
Camel-case field names cause failed reads
Open
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
It appears at least for the mongo backend that using camel case for field names leads to no functionality. A full example is on my github but the gist is:
share
[mkPersist mongoSettings]
[persistLowerCase|
BThing
anyInnerRecordWithCamelFieldsFails Int
deriving Show
AThing
record_field BThing
deriving Show
|]
main :: IO ()
main =
withMongoDBConn
"myDatabaseName"
"localhost"
(PortNumber 27017)
Nothing
2000
(runMongoDBPool
master
(do athing <- insert (AThing (BThing 1))
liftIO $ print athing
athingEnt <- selectList [] [] :: Action IO [Entity AThing]
liftIO $ print (map entityVal athingEnt)
return ()))
EDIT: Sorry, submitted too fast. Executing the above we get:
docker run --rm -d -p 27017:27017 mongo:3.6
cabal run
Up to date
MongoKey {unMongoKey = 5e69ebd7ccf0323fd5000000}
MongoPersist: PersistMarshalError "AThing: Couldn't parse field `record_field` from table `a_thing`. Couldn't parse field `anyInnerRecordWithCamelFieldsFails` from table `b_thing`. Failed to parse Haskell type `Int`; expected integer from database, but received: PersistNull. Potential solution: Check that your database schema matches your Persistent model definitions. for doc: [ _id: 5e69ebd7ccf0323fd5000000, record_field: [ any_inner_record_with_camel_fields_fails: 1]]"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example from the issue with the MongoDB backend and the linked toy-mongo-and-persistent project. Compare the persisted document's snake_case fields with the Haskell camel-case fields and trace the read path. Done means inserting and selecting the example records returns their original Int values instead of PersistNull.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, mongodb
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100