Skip to content

dinosql/internal: Ignore alter sequence commands #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/catalog/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Update(c *pg.Catalog, stmt nodes.Node) error {
if !ok {
return fmt.Errorf("expected RawStmt; got %T", stmt)
}

switch n := raw.Stmt.(type) {

case nodes.AlterObjectSchemaStmt:
Expand Down Expand Up @@ -97,6 +98,28 @@ func Update(c *pg.Catalog, stmt nodes.Node) error {
}

case nodes.AlterTableStmt:
var implemented bool
for _, item := range n.Cmds.Items {
switch cmd := item.(type) {
case nodes.AlterTableCmd:
switch cmd.Subtype {
case nodes.AT_AddColumn:
implemented = true
case nodes.AT_AlterColumnType:
implemented = true
case nodes.AT_DropColumn:
implemented = true
case nodes.AT_DropNotNull:
implemented = true
case nodes.AT_SetNotNull:
implemented = true
}
}
}

if !implemented {
return nil
}
fqn, err := ParseRange(n.Relation)
if err != nil {
return err
Expand Down