MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parseColumnName

Method parseColumnName

pkg/sql/parser/ddl_columns.go:32–49  ·  view source on GitHub ↗

parseColumnName parses a column name in DDL context, accepting reserved keywords like KEY, TABLE, INDEX as column names when context is unambiguous. In SQLite and other dialects, many reserved words may appear as column names.

()

Source from the content-addressed store, hash-verified

30// like KEY, TABLE, INDEX as column names when context is unambiguous.
31// In SQLite and other dialects, many reserved words may appear as column names.
32func (p *Parser) parseColumnName() *ast.Identifier {
33 val := p.currentToken.Token.Value
34 if val == "" {
35 return nil
36 }
37 // Accept identifiers, double-quoted identifiers, and any keyword token
38 // that could be used as a column name (e.g. KEY, TABLE, INDEX, etc.)
39 switch p.currentToken.Token.Type {
40 case models.TokenTypeEOF, models.TokenTypeComma, models.TokenTypeLParen,
41 models.TokenTypeRParen, models.TokenTypeSemicolon, models.TokenTypePeriod,
42 models.TokenTypeUnknown:
43 return nil
44 }
45 pos := p.currentLocation()
46 ident := &ast.Identifier{Name: val, Pos: pos}
47 p.advance()
48 return ident
49}
50
51// parseColumnDef parses a column definition including column constraints
52func (p *Parser) parseColumnDef() (*ast.ColumnDef, error) {

Callers 2

parseColumnDefMethod · 0.95
parsePeriodDefinitionMethod · 0.95

Calls 2

currentLocationMethod · 0.95
advanceMethod · 0.95

Tested by

no test coverage detected