From 2fe71f42ffd954652e233043a355a68cca18e299 Mon Sep 17 00:00:00 2001 From: Vivek Yadav Date: Fri, 22 Nov 2024 18:15:13 +0530 Subject: [PATCH] rename the constraint name --- internal/mapping.go | 2 +- sources/common/toddl.go | 6 +++--- sources/common/toddl_test.go | 2 +- spanner/ddl/ast.go | 6 +++--- spanner/ddl/ast_test.go | 4 ++-- webv2/api/schema.go | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/mapping.go b/internal/mapping.go index 1b955bdba..93f9f7f37 100644 --- a/internal/mapping.go +++ b/internal/mapping.go @@ -251,7 +251,7 @@ func ToSpannerCheckConstraintName(conv *Conv, srcCheckConstraintName string) str return getSpannerValidName(conv, srcCheckConstraintName) } -func GetSpannerValidExpression(cks []ddl.Checkconstraint) []ddl.Checkconstraint { +func GetSpannerValidExpression(cks []ddl.CheckConstraint) []ddl.CheckConstraint { // TODO validate the check constraints data with batch verification then send back return cks } diff --git a/sources/common/toddl.go b/sources/common/toddl.go index bf4379288..67b313521 100644 --- a/sources/common/toddl.go +++ b/sources/common/toddl.go @@ -235,11 +235,11 @@ func cvtForeignKeys(conv *internal.Conv, spTableName string, srcTableId string, return spKeys } -func cvtCheckConstraint(conv *internal.Conv, srcKeys []schema.CheckConstraints) []ddl.Checkconstraint { - var spcks []ddl.Checkconstraint +func cvtCheckConstraint(conv *internal.Conv, srcKeys []schema.CheckConstraints) []ddl.CheckConstraint { + var spcks []ddl.CheckConstraint for _, cks := range srcKeys { - spcks = append(spcks, ddl.Checkconstraint{ + spcks = append(spcks, ddl.CheckConstraint{ Id: cks.Id, Name: internal.ToSpannerCheckConstraintName(conv, cks.Name), Expr: cks.Expr, diff --git a/sources/common/toddl_test.go b/sources/common/toddl_test.go index fd1504a84..74ac72202 100644 --- a/sources/common/toddl_test.go +++ b/sources/common/toddl_test.go @@ -443,7 +443,7 @@ func Test_cvtCheckContraint(t *testing.T) { Expr: "age < 99", }, } - spSchema := []ddl.Checkconstraint{ + spSchema := []ddl.CheckConstraint{ { Id: "ck1", Name: "check_1", diff --git a/spanner/ddl/ast.go b/spanner/ddl/ast.go index d38db2105..366222bc4 100644 --- a/spanner/ddl/ast.go +++ b/spanner/ddl/ast.go @@ -264,7 +264,7 @@ type IndexKey struct { Order int } -type Checkconstraint struct { +type CheckConstraint struct { Id string Name string Expr string @@ -332,7 +332,7 @@ type CreateTable struct { ForeignKeys []Foreignkey Indexes []CreateIndex ParentTable InterleavedParent //if not empty, this table will be interleaved - CheckConstraint []Checkconstraint + CheckConstraint []CheckConstraint Comment string Id string } @@ -509,7 +509,7 @@ func (k Foreignkey) PrintForeignKeyAlterTable(spannerSchema Schema, c Config, ta } // PrintCheckConstraintTable unparses the check constraints using CHECK CONSTRAINTS. -func PrintCheckConstraintTable(cks []Checkconstraint) string { +func PrintCheckConstraintTable(cks []CheckConstraint) string { var s string s = "" diff --git a/spanner/ddl/ast_test.go b/spanner/ddl/ast_test.go index f55c22ed7..e424354b4 100644 --- a/spanner/ddl/ast_test.go +++ b/spanner/ddl/ast_test.go @@ -143,7 +143,7 @@ func TestPrintCreateTable(t *testing.T) { }, PrimaryKeys: []IndexKey{{ColId: "col1", Desc: true}}, ForeignKeys: nil, - CheckConstraint: []Checkconstraint{ + CheckConstraint: []CheckConstraint{ {Id: "ck1", Name: "check_1", Expr: "(age > 18)"}, {Id: "ck2", Name: "check_2", Expr: "(age < 99)"}, }, @@ -194,7 +194,7 @@ func TestPrintCreateTable(t *testing.T) { }, PrimaryKeys: nil, ForeignKeys: nil, - CheckConstraint: []Checkconstraint{ + CheckConstraint: []CheckConstraint{ {Id: "ck1", Name: "check_1", Expr: "(age > 18)"}, {Id: "ck2", Name: "check_2", Expr: "(age < 99)"}, }, diff --git a/webv2/api/schema.go b/webv2/api/schema.go index c1ea6d2be..08ceca5ec 100644 --- a/webv2/api/schema.go +++ b/webv2/api/schema.go @@ -503,7 +503,7 @@ func UpdateCheckConstraint(w http.ResponseWriter, r *http.Request) { sessionState.Conv.ConvLock.Lock() defer sessionState.Conv.ConvLock.Unlock() - newCKs := []ddl.Checkconstraint{} + newCKs := []ddl.CheckConstraint{} if err = json.Unmarshal(reqBody, &newCKs); err != nil { http.Error(w, fmt.Sprintf("Request Body parse error : %v", err), http.StatusBadRequest) return @@ -526,7 +526,7 @@ func UpdateCheckConstraint(w http.ResponseWriter, r *http.Request) { } -func doesNameExist(spcks []ddl.Checkconstraint, targetName string) bool { +func doesNameExist(spcks []ddl.CheckConstraint, targetName string) bool { for _, spck := range spcks { if strings.Contains(spck.Expr, targetName) { return true