jinzhu/gorm — pull request #313 by galeone (2014-12-08 11:06:42+00:00)
Title: Avoid Errors in PostgreSQL when creating a row without a GORM primary key

Hi,
when we have a multiple-field primary key defined db-size on an existing schema we can't define a multiple-field primary key in gorm struct.

This is not a problem, in general since tables with more than one field used as primary key are usually join tables (if the logical project was doing well), but is a problem when we want to create manually an entry into this table using gorm a postgres.

In the `create_callback.go` we do the right query and than we add at the and of the string ` "RETURNING "` concatenated with the primary key field.

But if we are in a situation like the one described above (e.g we have a struct like that
```go
typedef JoinTable struct {
From uint64
To uint64
}
```
Where on db-size the primary key is ("from","to") )

the generated creation query is
```sql
INSERT INTO join_table("from","to") VALUES(x,x) RETURNING ""
```
The empty string in the returning field makes the query fail.

With this pull request I fix this issue, returning "RETURNING" concatenated with the table name . (dot) field if the primary key is defined or returning "RETURNING" table table.* if no primary key is defined in gorm.