Skip to content

Commit

Permalink
Rename alternation to alteration for clarity (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
toga4 authored Oct 22, 2023
1 parent 9bdd6e4 commit 9cf0b5b
Show file tree
Hide file tree
Showing 58 changed files with 135 additions and 135 deletions.
66 changes: 33 additions & 33 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,22 @@ type Constraint interface {
func (ForeignKey) isConstraint() {}
func (Check) isConstraint() {}

// TableAlternation represents ALTER TABLE action.
type TableAlternation interface {
// TableAlteration represents ALTER TABLE action.
type TableAlteration interface {
Node
isTableAlternation()
isTableAlteration()
}

func (AddColumn) isTableAlternation() {}
func (AddTableConstraint) isTableAlternation() {}
func (AddRowDeletionPolicy) isTableAlternation() {}
func (DropColumn) isTableAlternation() {}
func (DropConstraint) isTableAlternation() {}
func (DropRowDeletionPolicy) isTableAlternation() {}
func (ReplaceRowDeletionPolicy) isTableAlternation() {}
func (SetOnDelete) isTableAlternation() {}
func (AlterColumn) isTableAlternation() {}
func (AlterColumnSet) isTableAlternation() {}
func (AddColumn) isTableAlteration() {}
func (AddTableConstraint) isTableAlteration() {}
func (AddRowDeletionPolicy) isTableAlteration() {}
func (DropColumn) isTableAlteration() {}
func (DropConstraint) isTableAlteration() {}
func (DropRowDeletionPolicy) isTableAlteration() {}
func (ReplaceRowDeletionPolicy) isTableAlteration() {}
func (SetOnDelete) isTableAlteration() {}
func (AlterColumn) isTableAlteration() {}
func (AlterColumnSet) isTableAlteration() {}

// Privilege represents privileges specified by GRANT and REVOKE.
type Privilege interface {
Expand Down Expand Up @@ -294,14 +294,14 @@ func (ScalarSchemaType) isSchemaType() {}
func (SizedSchemaType) isSchemaType() {}
func (ArraySchemaType) isSchemaType() {}

// IndexAlternation represents ALTER INDEX action.
type IndexAlternation interface {
// IndexAlteration represents ALTER INDEX action.
type IndexAlteration interface {
Node
isIndexAlternation()
isIndexAlteration()
}

func (AddStoredColumn) isIndexAlternation() {}
func (DropStoredColumn) isIndexAlternation() {}
func (AddStoredColumn) isIndexAlteration() {}
func (DropStoredColumn) isIndexAlteration() {}

// DML represents data manipulation language in SQL.
//
Expand Down Expand Up @@ -333,15 +333,15 @@ type ChangeStreamFor interface {
func (ChangeStreamForAll) isChangeStreamFor() {}
func (ChangeStreamForTables) isChangeStreamFor() {}

// ChangeStreamAlternation represents ALTER CHANGE STREAM action.
type ChangeStreamAlternation interface {
// ChangeStreamAlteration represents ALTER CHANGE STREAM action.
type ChangeStreamAlteration interface {
Node
isChangeStreamAlternation()
isChangeStreamAlteration()
}

func (ChangeStreamSetFor) isChangeStreamAlternation() {}
func (ChangeStreamDropForAll) isChangeStreamAlternation() {}
func (ChangeStreamSetOptions) isChangeStreamAlternation() {}
func (ChangeStreamSetFor) isChangeStreamAlteration() {}
func (ChangeStreamDropForAll) isChangeStreamAlteration() {}
func (ChangeStreamSetOptions) isChangeStreamAlteration() {}

// ================================================================================
//
Expand Down Expand Up @@ -1626,41 +1626,41 @@ type CreateView struct {

// AlterTable is ALTER TABLE statement node.
//
// ALTER TABLE {{.Name | sql}} {{.TableAlternation | sql}}
// ALTER TABLE {{.Name | sql}} {{.TableAlteration | sql}}
type AlterTable struct {
// pos = Alter
// end = TableAlternation.end
// end = TableAlteration.end

Alter token.Pos // position of "ALTER" keyword

Name *Ident
TableAlternation TableAlternation
TableAlteration TableAlteration
}

// AlterIndex is ALTER INDEX statement node.
//
// ALTER INDEX {{.Name | sql}} {{.IndexAlternation | sql}}
// ALTER INDEX {{.Name | sql}} {{.IndexAlteration | sql}}
type AlterIndex struct {
// pos = Alter
// end = IndexAlternation.end
// end = IndexAlteration.end

Alter token.Pos // position of "ALTER" keyword

Name *Ident
IndexAlternation IndexAlternation
IndexAlteration IndexAlteration
}

// AlterChangeStream is ALTER CHANGE STREAM statement node.
//
// ALTER CHANGE STREAM {{.Name | sql}} {{.ChangeStreamAlternation | sql}}
// ALTER CHANGE STREAM {{.Name | sql}} {{.ChangeStreamAlteration | sql}}
type AlterChangeStream struct {
// pos = Alter
// end = ChangeStreamAlternation.end
// end = ChangeStreamAlteration.end

Alter token.Pos // position of "ALTER" keyword

Name *Ident
ChangeStreamAlternation ChangeStreamAlternation
ChangeStreamAlteration ChangeStreamAlteration
}

// AddColumn is ADD COLUMN clause in ALTER TABLE.
Expand Down
22 changes: 11 additions & 11 deletions ast/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ func TestConstraint(t *testing.T) {
Constraint(&Check{}).isConstraint()
}

func TestTableAlternation(t *testing.T) {
TableAlternation(&AddColumn{}).isTableAlternation()
TableAlternation(&AddTableConstraint{}).isTableAlternation()
TableAlternation(&DropColumn{}).isTableAlternation()
TableAlternation(&DropConstraint{}).isTableAlternation()
TableAlternation(&SetOnDelete{}).isTableAlternation()
TableAlternation(&AlterColumn{}).isTableAlternation()
TableAlternation(&AlterColumnSet{}).isTableAlternation()
func TestTableAlteration(t *testing.T) {
TableAlteration(&AddColumn{}).isTableAlteration()
TableAlteration(&AddTableConstraint{}).isTableAlteration()
TableAlteration(&DropColumn{}).isTableAlteration()
TableAlteration(&DropConstraint{}).isTableAlteration()
TableAlteration(&SetOnDelete{}).isTableAlteration()
TableAlteration(&AlterColumn{}).isTableAlteration()
TableAlteration(&AlterColumnSet{}).isTableAlteration()
}

func TestPrivilege(t *testing.T) {
Expand All @@ -172,9 +172,9 @@ func TestSchemaType(t *testing.T) {
SchemaType(&ArraySchemaType{}).isSchemaType()
}

func TestIndexAlternation(t *testing.T) {
IndexAlternation(&AddStoredColumn{}).isIndexAlternation()
IndexAlternation(&DropStoredColumn{}).isIndexAlternation()
func TestIndexAlteration(t *testing.T) {
IndexAlteration(&AddStoredColumn{}).isIndexAlteration()
IndexAlteration(&DropStoredColumn{}).isIndexAlteration()
}

func TestDML(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions ast/pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func (r *RowDeletionPolicy) End() token.Pos {
}

func (a *AlterTable) Pos() token.Pos { return a.Alter }
func (a *AlterTable) End() token.Pos { return a.TableAlternation.End() }
func (a *AlterTable) End() token.Pos { return a.TableAlteration.End() }

func (a *AddColumn) Pos() token.Pos { return a.Add }
func (a *AddColumn) End() token.Pos { return a.Column.End() }
Expand Down Expand Up @@ -693,7 +693,7 @@ func (i *InterleaveIn) Pos() token.Pos { return i.Comma }
func (i *InterleaveIn) End() token.Pos { return i.TableName.End() }

func (a *AlterIndex) Pos() token.Pos { return a.Alter }
func (a *AlterIndex) End() token.Pos { return a.IndexAlternation.End() }
func (a *AlterIndex) End() token.Pos { return a.IndexAlteration.End() }

func (a *AddStoredColumn) Pos() token.Pos { return a.Add }
func (a *AddStoredColumn) End() token.Pos { return a.Name.End() }
Expand All @@ -714,7 +714,7 @@ func (d *DropChangeStream) Pos() token.Pos { return d.Drop }
func (d *DropChangeStream) End() token.Pos { return d.Name.End() }

func (a *AlterChangeStream) Pos() token.Pos { return a.Alter }
func (a *AlterChangeStream) End() token.Pos { return a.ChangeStreamAlternation.End() }
func (a *AlterChangeStream) End() token.Pos { return a.ChangeStreamAlteration.End() }

func (a *ChangeStreamSetFor) Pos() token.Pos { return a.Set }
func (a *ChangeStreamSetFor) End() token.Pos { return a.For.End() }
Expand Down
2 changes: 1 addition & 1 deletion ast/pos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cloudspannerecosystem/memefish/token"
)

func TestTableAlternation_Position(t *testing.T) {
func TestTableAlteration_Position(t *testing.T) {
alterColumnDefaultExpr := AlterColumn{
DefaultExpr: &ColumnDefaultExpr{Rparen: 100},
}
Expand Down
6 changes: 3 additions & 3 deletions ast/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ func (r *RowDeletionPolicy) SQL() string {
}

func (a *AlterTable) SQL() string {
return "ALTER TABLE " + a.Name.SQL() + " " + a.TableAlternation.SQL()
return "ALTER TABLE " + a.Name.SQL() + " " + a.TableAlteration.SQL()
}

func (a *AddColumn) SQL() string {
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func (c *ChangeStreamOptions) SQL() string {
}

func (a *AlterChangeStream) SQL() string {
return "ALTER CHANGE STREAM " + a.Name.SQL() + " " + a.ChangeStreamAlternation.SQL()
return "ALTER CHANGE STREAM " + a.Name.SQL() + " " + a.ChangeStreamAlteration.SQL()
}

func (a ChangeStreamSetFor) SQL() string {
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (i *InterleaveIn) SQL() string {
}

func (a *AlterIndex) SQL() string {
return "ALTER INDEX " + a.Name.SQL() + " " + a.IndexAlternation.SQL()
return "ALTER INDEX " + a.Name.SQL() + " " + a.IndexAlteration.SQL()
}

func (a *AddStoredColumn) SQL() string {
Expand Down
Loading

0 comments on commit 9cf0b5b

Please sign in to comment.