// SetKeys lets you specify the fields on a struct that map to primary // key columns on the table. If isAutoIncr is set, result.LastInsertId() // will be used after INSERT to bind the generated id to the Go struct. // // Automatically calls ResetSql() to ensure SQL statements are regenerated. func (t *TableMap) SetKeys(isAutoIncr bool, fieldNames ...string) *TableMap { t.Keys = make([]*ColumnMap, 0) for _, name := range fieldNames { // FIXME: sqlx.NameMapper is a deprecated API. modl should have its // own API which sets sqlx's mapping funcs as necessary colmap := t.ColMap(sqlx.NameMapper(name)) colmap.isPK = true colmap.isAutoIncr = isAutoIncr t.Keys = append(t.Keys, colmap) } t.ResetSql() return t }
// QuoteField quotes f with "" func (d PostgresDialect) QuoteField(f string) string { return `"` + sqlx.NameMapper(f) + `"` }