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

Method isExistColumn

internal/sql/catalog/table.go:31–42  ·  view source on GitHub ↗
(cmd *ast.AlterTableCmd)

Source from the content-addressed store, hash-verified

29}
30
31func (table *Table) isExistColumn(cmd *ast.AlterTableCmd) (int, error) {
32 for i, c := range table.Columns {
33 if c.Name == *cmd.Name {
34 return i, nil
35 }
36 }
37 if !cmd.MissingOk {
38 return -1, sqlerr.ColumnNotFound(table.Rel.Name, *cmd.Name)
39 }
40 // Missing column is allowed
41 return -1, nil
42}
43
44func (c *Catalog) addColumn(table *Table, cmd *ast.AlterTableCmd) error {
45 for _, c := range table.Columns {

Callers 4

alterColumnTypeMethod · 0.95
dropNotNullMethod · 0.95
setNotNullMethod · 0.95
dropColumnMethod · 0.80

Calls 1

ColumnNotFoundFunction · 0.92

Tested by

no test coverage detected