parseQualifiedName parses a potentially schema-qualified name (e.g., schema.table or db.schema.table). Returns the full dotted name as a string. Supports up to 3-part names.
()
| 1024 | // parseQualifiedName parses a potentially schema-qualified name (e.g., schema.table or db.schema.table). |
| 1025 | // Returns the full dotted name as a string. Supports up to 3-part names. |
| 1026 | func (p *Parser) parseQualifiedName() (string, error) { |
| 1027 | if !p.isIdentifier() && !p.isNonReservedKeyword() { |
| 1028 | return "", p.expectedError("identifier") |
| 1029 | } |
| 1030 | name := p.currentToken.Token.Value |
| 1031 | p.advance() |
| 1032 | |
| 1033 | // Check for schema.table or db.schema.table |
| 1034 | for p.isType(models.TokenTypePeriod) { |
| 1035 | p.advance() // Consume . |
| 1036 | if !p.isIdentifier() && !p.isNonReservedKeyword() { |
| 1037 | return "", p.expectedError("identifier after .") |
| 1038 | } |
| 1039 | name = name + "." + p.currentToken.Token.Value |
| 1040 | p.advance() |
| 1041 | } |
| 1042 | |
| 1043 | return name, nil |
| 1044 | } |
| 1045 | |
| 1046 | // Accepts IDENT or non-reserved keywords that can be used as table names |
| 1047 | func (p *Parser) parseTableReference() (*ast.TableReference, error) { |
no test coverage detected