Skip to content

Commit

Permalink
Merge pull request #191 from ioito/hotfix/qx-more-details-columns-error
Browse files Browse the repository at this point in the history
fix: add more columns error
  • Loading branch information
ioito authored Apr 17, 2024
2 parents 96da8bf + 0575639 commit 4f4271c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,20 @@ func (ts *STableSpec) SyncColumnIndexes() error {

cols, err := ts.Database().backend.FetchTableColumnSpecs(ts)
if err != nil {
log.Errorf("fetchColumnDefs fail: %s", err)
return errors.Wrap(err, "FetchTableColumnSpecs")
}
if len(cols) != len(ts._columns) {
return errors.Wrapf(errors.ErrInvalidStatus, "ts col %d != actual col %d", len(ts._columns), len(cols))
colsName := map[string]bool{}
for _, col := range ts._columns {
colsName[col.Name()] = true
}
removed := []string{}
for _, col := range cols {
if _, ok := colsName[col.Name()]; !ok {
removed = append(removed, col.Name())
}
}
return errors.Wrapf(errors.ErrInvalidStatus, "ts %s col %d != actual col %d need remove columns %s", ts.Name(), len(ts._columns), len(cols), removed)
}
for i := range cols {
cols[i].SetColIndex(i)
Expand Down

0 comments on commit 4f4271c

Please sign in to comment.