From 84f86a605c809ab36dd3cb4b3ab1df15a5302083 Mon Sep 17 00:00:00 2001 From: Ryoya Sekino Date: Mon, 16 Aug 2021 18:59:00 +0900 Subject: [PATCH] feat(spannertest): Add validation of duplicated column names (#4611) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Co-authored-by: Knut Olav Løite --- spanner/spannertest/db.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spanner/spannertest/db.go b/spanner/spannertest/db.go index dae4b50a120..b58751ab650 100644 --- a/spanner/spannertest/db.go +++ b/spanner/spannertest/db.go @@ -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()