Skip to content

Commit

Permalink
rename the constraint name
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Yadav committed Nov 22, 2024
1 parent 4c22d00 commit 2fe71f4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions sources/common/toddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sources/common/toddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func Test_cvtCheckContraint(t *testing.T) {
Expr: "age < 99",
},
}
spSchema := []ddl.Checkconstraint{
spSchema := []ddl.CheckConstraint{
{
Id: "ck1",
Name: "check_1",
Expand Down
6 changes: 3 additions & 3 deletions spanner/ddl/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ type IndexKey struct {
Order int
}

type Checkconstraint struct {
type CheckConstraint struct {
Id string
Name string
Expr string
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 = ""
Expand Down
4 changes: 2 additions & 2 deletions spanner/ddl/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)"},
},
Expand Down Expand Up @@ -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)"},
},
Expand Down
4 changes: 2 additions & 2 deletions webv2/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2fe71f4

Please sign in to comment.