MCPcopy
hub / github.com/sqlc-dev/sqlc / addColumn

Method addColumn

internal/sql/catalog/table.go:44–59  ·  view source on GitHub ↗
(table *Table, cmd *ast.AlterTableCmd)

Source from the content-addressed store, hash-verified

42}
43
44func (c *Catalog) addColumn(table *Table, cmd *ast.AlterTableCmd) error {
45 for _, c := range table.Columns {
46 if c.Name == cmd.Def.Colname {
47 if !cmd.MissingOk {
48 return sqlerr.ColumnExists(table.Rel.Name, cmd.Def.Colname)
49 }
50 return nil
51 }
52 }
53 tc, err := c.defineColumn(table.Rel, cmd.Def)
54 if err != nil {
55 return err
56 }
57 table.Columns = append(table.Columns, tc)
58 return nil
59}
60
61func (table *Table) alterColumnType(cmd *ast.AlterTableCmd) error {
62 index, err := table.isExistColumn(cmd)

Callers 1

alterTableMethod · 0.95

Calls 2

defineColumnMethod · 0.95
ColumnExistsFunction · 0.92

Tested by

no test coverage detected