AddTableWithNameAndSchema has the same behavior as AddTable, but sets table.TableName to name.
(i interface{}, schema string, name string)
| 222 | // AddTableWithNameAndSchema has the same behavior as AddTable, but sets |
| 223 | // table.TableName to name. |
| 224 | func (m *DbMap) AddTableWithNameAndSchema(i interface{}, schema string, name string) *TableMap { |
| 225 | t := reflect.TypeOf(i) |
| 226 | if name == "" { |
| 227 | name = t.Name() |
| 228 | } |
| 229 | |
| 230 | // check if we have a table for this type already |
| 231 | // if so, update the name and return the existing pointer |
| 232 | for i := range m.tables { |
| 233 | table := m.tables[i] |
| 234 | if table.gotype == t { |
| 235 | table.TableName = name |
| 236 | return table |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | tmap := &TableMap{gotype: t, TableName: name, SchemaName: schema, dbmap: m} |
| 241 | var primaryKey []*ColumnMap |
| 242 | tmap.Columns, primaryKey = m.readStructColumns(t) |
| 243 | m.tables = append(m.tables, tmap) |
| 244 | if len(primaryKey) > 0 { |
| 245 | tmap.keys = append(tmap.keys, primaryKey...) |
| 246 | } |
| 247 | |
| 248 | return tmap |
| 249 | } |
| 250 | |
| 251 | // AddTableDynamic registers the given interface type with gorp. |
| 252 | // The table name will be dynamically determined at runtime by |
no test coverage detected