Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins committed Feb 18, 2024
1 parent 503af42 commit 6479393
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions label.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ func (edge LabelSchema) BuildDropEdgeQL() string {
return q
}

func (field LabelFieldSchema) BuildAddFieldQL(labelName string) string {
func (field LabelFieldSchema) BuildAddTagFieldQL(labelName string) string {
q := "ALTER TAG " + labelName + " ADD (" + field.Field + " " + field.Type
if !field.Nullable {
q += " NOT NULL"
}
return q + ");"
}

func (field Label) BuildDropFieldQL(labelName string) string {
func (field Label) BuildDropTagFieldQL(labelName string) string {
return "ALTER TAG " + labelName + " DROP (" + field.Field + ");"
}

Expand Down
6 changes: 3 additions & 3 deletions label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func TestBuildAddFieldQL(t *testing.T) {
Type: "string",
Nullable: false,
}
assert.Equal(t, "ALTER TAG account ADD (name string NOT NULL);", field.BuildAddFieldQL("account"))
assert.Equal(t, "ALTER TAG account ADD (name string NOT NULL);", field.BuildAddTagFieldQL("account"))
field.Nullable = true
assert.Equal(t, "ALTER TAG account ADD (name string);", field.BuildAddFieldQL("account"))
assert.Equal(t, "ALTER TAG account ADD (name string);", field.BuildAddTagFieldQL("account"))
}

func TestBuildDropFieldQL(t *testing.T) {
field := Label{
Field: "name",
}
assert.Equal(t, "ALTER TAG account DROP (name);", field.BuildDropFieldQL("account"))
assert.Equal(t, "ALTER TAG account DROP (name);", field.BuildDropTagFieldQL("account"))
}
4 changes: 2 additions & 2 deletions session_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (pool *SessionPool) ApplyTag(tag LabelSchema) (*ResultSet, error) {
}
if !found {
// 4.2 Add the not exists field
q := expected.BuildAddFieldQL(tag.Name)
q := expected.BuildAddTagFieldQL(tag.Name)
_, err := pool.ExecuteAndCheck(q)
if err != nil {
return nil, err
Expand All @@ -384,7 +384,7 @@ func (pool *SessionPool) ApplyTag(tag LabelSchema) (*ResultSet, error) {
}
if redundant {
// 5.1 Remove the not expected field
q := actual.BuildDropFieldQL(tag.Name)
q := actual.BuildDropTagFieldQL(tag.Name)
_, err := pool.ExecuteAndCheck(q)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6479393

Please sign in to comment.