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

Method defineColumn

internal/sql/catalog/table.go:331–354  ·  view source on GitHub ↗
(table *ast.TableName, col *ast.ColumnDef)

Source from the content-addressed store, hash-verified

329}
330
331func (c *Catalog) defineColumn(table *ast.TableName, col *ast.ColumnDef) (*Column, error) {
332 tc := &Column{
333 Name: col.Colname,
334 Type: *col.TypeName,
335 IsNotNull: col.IsNotNull,
336 IsUnsigned: col.IsUnsigned,
337 IsArray: col.IsArray,
338 ArrayDims: col.ArrayDims,
339 Comment: col.Comment,
340 Length: col.Length,
341 }
342 if col.Vals != nil {
343 typeName := ast.TypeName{
344 Name: fmt.Sprintf("%s_%s", table.Name, col.Colname),
345 }
346 s := &ast.CreateEnumStmt{TypeName: &typeName, Vals: col.Vals}
347 if err := c.createEnum(s); err != nil {
348 return nil, err
349 }
350 tc.Type = typeName
351 tc.linkedType = true
352 }
353 return tc, nil
354}
355
356func (c *Catalog) dropTable(stmt *ast.DropTableStmt) error {
357 for _, name := range stmt.Tables {

Callers 2

addColumnMethod · 0.95
createTableMethod · 0.95

Calls 1

createEnumMethod · 0.95

Tested by

no test coverage detected