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

Expand composite primary keys in raw sql.