(tableName string)
| 241 | } |
| 242 | |
| 243 | func (c *Client) getTableInfo(tableName string) (*tableInfo, error) { |
| 244 | info := tableInfo{} |
| 245 | rows, err := c.db.Query(fmt.Sprintf(sqlTableInfo, tableName)) |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | defer rows.Close() |
| 250 | for rows.Next() { |
| 251 | colInfo := columnInfo{} |
| 252 | if err := rows.Scan( |
| 253 | &colInfo.index, |
| 254 | &colInfo.name, |
| 255 | &colInfo.typ, |
| 256 | &colInfo.notNull, |
| 257 | &colInfo.defaultValue, |
| 258 | &colInfo.pk); err != nil { |
| 259 | return nil, err |
| 260 | } |
| 261 | colInfo.typ = strings.ToLower(colInfo.typ) |
| 262 | info.columns = append(info.columns, colInfo) |
| 263 | } |
| 264 | if err := rows.Err(); err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | |
| 268 | if len(info.columns) == 0 { |
| 269 | // Table doesn't exist |
| 270 | return nil, nil |
| 271 | } |
| 272 | return &info, nil |
| 273 | } |
no test coverage detected