Table gets Table definition for given table name
(tableIn string)
| 208 | |
| 209 | // Table gets Table definition for given table name |
| 210 | func (m *Schema) Table(tableIn string) (*Table, error) { |
| 211 | |
| 212 | tableName := strings.ToLower(tableIn) |
| 213 | |
| 214 | m.mu.RLock() |
| 215 | defer m.mu.RUnlock() |
| 216 | |
| 217 | // u.Debugf("%p looking up %q", m, tableName) |
| 218 | |
| 219 | tbl, ok := m.tableMap[tableName] |
| 220 | if ok && tbl != nil { |
| 221 | return tbl, nil |
| 222 | } |
| 223 | |
| 224 | // Lets see if it is `schema`.`table` format |
| 225 | _, tableName, ok = expr.LeftRight(tableName) |
| 226 | if ok { |
| 227 | tbl, ok = m.tableMap[tableName] |
| 228 | if ok && tbl != nil { |
| 229 | return tbl, nil |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | if m.SchemaRef != nil { |
| 234 | return m.SchemaRef.Table(tableIn) |
| 235 | } |
| 236 | return nil, fmt.Errorf("Could not find that table: %v", tableIn) |
| 237 | } |
| 238 | |
| 239 | // OpenConn get a connection from this schema by table name. |
| 240 | func (m *Schema) OpenConn(tableName string) (Conn, error) { |