yesodweb/persistent — pull request #178 by BJTerry (2013-10-14 10:53:06+00:00)
Title: Make TH function fromPersistValue work with any field ordering.

This addresses #176 and #177.

The issue is that Aeson doesn't guarantee the ordering of fields in serialized/deserialized objects. So, for example in ghci:
````
fromJust $ decode $ encode $ toJSON $ toPersistValue $ Bar "b" "u" "g" :: PersistValue
PersistMap [("b",PersistText "b"),("g",PersistText "g"),("u",PersistText "u")]
````
The code for fromPersistValue assumed that the ordering matched the original column ordering. This patch causes the generated fromPersistValue to lookup each column name in the PersistMap list. It passes the test from #177 in sqlite, postgres and MySQL (not tested with Mongo). Repeated use of lookup also makes fromPersistValue O(n^2) in the number of columns rather than O(n) in the original, which may be an issue for performance, but I don't have a very good heuristic sense on whether that matters.