File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -320,29 +320,31 @@ func (table *table) initColumnData() error {
320
320
scans [i ] = & info [i ]
321
321
}
322
322
323
+ fieldIndex , extraIndex := - 1 , - 1
324
+ for i , col := range cols {
325
+ switch col {
326
+ case "Field" , "field" :
327
+ fieldIndex = i
328
+ case "Extra" , "extra" :
329
+ extraIndex = i
330
+ }
331
+ if fieldIndex > 0 && extraIndex > 0 {
332
+ break
333
+ }
334
+ }
335
+ if fieldIndex <= 0 || extraIndex < 0 {
336
+ return errors .New ("database column information is malformed" )
337
+ }
338
+
323
339
var result []string
324
340
for colInfo .Next () {
325
341
// Read into the pointers to the info marker
326
342
if err := colInfo .Scan (scans ... ); err != nil {
327
343
return err
328
344
}
329
345
330
- // Find the the fields we care about
331
- var field , extra * sql.NullString
332
- for i , col := range cols {
333
- switch col {
334
- case "Field" , "field" :
335
- field = & info [i ]
336
- case "Extra" , "extra" :
337
- extra = & info [i ]
338
- }
339
- if field != nil && extra != nil {
340
- break
341
- }
342
- }
343
-
344
- if ! extra .Valid || ! strings .Contains (extra .String , "VIRTUAL" ) {
345
- result = append (result , field .String )
346
+ if ! info [extraIndex ].Valid || ! strings .Contains (info [extraIndex ].String , "VIRTUAL" ) {
347
+ result = append (result , info [fieldIndex ].String )
346
348
}
347
349
}
348
350
table .cols = result
You can’t perform that action at this time.
0 commit comments