Skip to content

Commit

Permalink
feat(spannertest): Add validation of duplicated column names (#4611)
Browse files Browse the repository at this point in the history
* feat(spannertest): add validation for duplicated column names

* feat(spannertest): fix error message in validation of duplicated column

Co-authored-by: Knut Olav Løite <koloite@gmail.com>

Co-authored-by: Knut Olav Løite <koloite@gmail.com>
  • Loading branch information
sryoya and olavloite authored Aug 16, 2021
1 parent 7d85249 commit 84f86a6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spanner/spannertest/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ func (t *table) addColumn(cd spansql.ColumnDef, newTable bool) *status.Status {
return status.Newf(codes.InvalidArgument, "new non-key columns cannot be NOT NULL")
}

if _, ok := t.colIndex[cd.Name]; ok {
return status.Newf(codes.AlreadyExists, "column %s already exists", cd.Name)
}

t.mu.Lock()
defer t.mu.Unlock()

Expand Down

0 comments on commit 84f86a6

Please sign in to comment.