Issue #317 `replace` does not use `Primary` keys

Expand composite primary keys in raw sql.
Factored out common code to generate 'where' stmt from key.

Also, fixed test failing for MySQL.
Fixed PG unittests

Also bumped postgresql-simple requirement to match the one in persistent-postgresql
Merge pull request #318 from lbolla/issue-317

Issue #317 `replace` does not use `Primary` keys