Skip to content

Commit

Permalink
Merge pull request #1 from dashhudson/ignore-column-order
Browse files Browse the repository at this point in the history
Ignore column order
  • Loading branch information
pmdarrow authored May 11, 2023
2 parents 2ba8464 + 6c82315 commit fc6899b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### ⚠️ This is a fork of Skeema that's configured to ignore column order ⚠️
This is a feature that's [been requested](https://github.com/skeema/skeema/issues/178) but has had no movement.

[![Skeema](https://www.skeema.io/img/logo.png)](https://www.skeema.io)

[![build status](https://img.shields.io/github/actions/workflow/status/skeema/skeema/tests.yml?branch=main)](https://github.com/skeema/skeema/actions)
Expand Down
15 changes: 2 additions & 13 deletions internal/tengo/alterclause.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,26 +282,15 @@ var reDisplayWidth = regexp.MustCompile(`(tinyint|smallint|mediumint|int|bigint)

// Clause returns a MODIFY COLUMN clause of an ALTER TABLE statement.
func (mc ModifyColumn) Clause(mods StatementModifiers) string {
var positionClause string
if mc.PositionFirst {
// Positioning variables are mutually exclusive
if mc.PositionAfter != nil {
panic(fmt.Errorf("Modified column %s cannot be both first and after another column", mc.NewColumn.Name))
}
positionClause = " FIRST"
} else if mc.PositionAfter != nil {
positionClause = fmt.Sprintf(" AFTER %s", EscapeIdentifier(mc.PositionAfter.Name))
}

// Emit a no-op if we're not re-ordering the column and it only has cosmetic
// differences, such as presence/lack of int display width, or presence/lack
// of charset/collation clauses that are equal to the table's defaults anyway.
// (These situations only come up in MySQL 8, under various edge cases.)
if !mods.StrictColumnDefinition && positionClause == "" && mc.OldColumn.Equivalent(mc.NewColumn) {
if !mods.StrictColumnDefinition && mc.OldColumn.Equivalent(mc.NewColumn) {
return ""
}

return fmt.Sprintf("MODIFY COLUMN %s%s", mc.NewColumn.Definition(mods.Flavor, mc.Table), positionClause)
return fmt.Sprintf("MODIFY COLUMN %s", mc.NewColumn.Definition(mods.Flavor, mc.Table))
}

// Unsafe returns true if this clause is potentially destructive of data.
Expand Down

0 comments on commit fc6899b

Please sign in to comment.