coopernurse/gorp — pull request #160 by nelsam (2014-04-17 21:45:16+00:00)
Title: Support for Non-Integer Primary Keys

PostgreSQL supports automatically generated values of many types, not only automatically incremented integers. In our application, some tables have uuid primary key values, which are automatically generated strings.

I tried to find a way to support this without breaking any existing functionality, and I think this pulls it off without being too ugly. Here's a summary of what has changed:

1. `InsertAutoIncr` has been moved from the `Dialect` interface to the `IntegerAutoIncrInserter` interface
2. There is a new interface called `TargetedAutoIncrInserter`, which requires `InsertAutoIncrToTarget` to accept a `target` (of type `interface{}`) to assign the automatically generated ID to. Technically, `InsertAutoIncrToTarget` could have been named the same (`InsertAutoIncr`), but I wanted to separate the two types a bit more.
3. In the `insert` function, there is a type switch to detect which method should be called. If the dialect implements `IntegerAutoIncrInserter`, the logic used is the same as before. If the dialect implements `TargetedAutoIncrInserter`, the logic used is simpler - a pointer to the primary key field is passed as the target.

Let me know if you'd like anything changed.