From c1f3e6bde28ce5e0cc7a5914bef1fabcbcea803e Mon Sep 17 00:00:00 2001 From: sryoya Date: Fri, 13 Aug 2021 20:32:45 +0900 Subject: [PATCH 1/2] feat(spannertest): add validation for duplicated column names --- spanner/spannertest/db.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spanner/spannertest/db.go b/spanner/spannertest/db.go index dae4b50a120..a7d723c41a8 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.InvalidArgument, "duplicated column names: %s", cd.Name) + } + t.mu.Lock() defer t.mu.Unlock() From 5370f217aacf4415ca73b64da7a0d7d9c41bdf9e Mon Sep 17 00:00:00 2001 From: Ryoya Sekino Date: Mon, 16 Aug 2021 16:59:57 +0900 Subject: [PATCH 2/2] feat(spannertest): fix error message in validation of duplicated column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Knut Olav Løite --- spanner/spannertest/db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spanner/spannertest/db.go b/spanner/spannertest/db.go index a7d723c41a8..b58751ab650 100644 --- a/spanner/spannertest/db.go +++ b/spanner/spannertest/db.go @@ -623,7 +623,7 @@ func (t *table) addColumn(cd spansql.ColumnDef, newTable bool) *status.Status { } if _, ok := t.colIndex[cd.Name]; ok { - return status.Newf(codes.InvalidArgument, "duplicated column names: %s", cd.Name) + return status.Newf(codes.AlreadyExists, "column %s already exists", cd.Name) } t.mu.Lock()