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

Method parseTemporalPointExpression

pkg/sql/parser/mariadb.go:335–353  ·  view source on GitHub ↗

parseTemporalPointExpression parses a temporal point expression for FOR SYSTEM_TIME clauses. Handles typed string literals like TIMESTAMP '2024-01-01' and DATE '2024-01-01', as well as plain string literals and other primary expressions.

()

Source from the content-addressed store, hash-verified

333// Handles typed string literals like TIMESTAMP '2024-01-01' and DATE '2024-01-01',
334// as well as plain string literals and other primary expressions.
335func (p *Parser) parseTemporalPointExpression() (ast.Expression, error) {
336 // Handle TIMESTAMP 'str', DATE 'str', TIME 'str' typed literals.
337 word := strings.ToUpper(p.currentToken.Token.Value)
338 if word == "TIMESTAMP" || word == "DATE" || word == "TIME" {
339 typeKeyword := p.currentToken.Token.Value
340 p.advance()
341 if !p.isStringLiteral() {
342 return nil, fmt.Errorf("expected string literal after %s, got %q", typeKeyword, p.currentToken.Token.Value)
343 }
344 // The tokenizer strips surrounding single quotes from string literal tokens,
345 // so p.currentToken.Token.Value is the raw string content (e.g. "2023-01-01 00:00:00").
346 // We reconstruct the canonical form: TYPE 'value'.
347 value := typeKeyword + " '" + p.currentToken.Token.Value + "'"
348 p.advance()
349 return &ast.LiteralValue{Value: value, Type: "timestamp"}, nil
350 }
351 // Fall back to primary expression (handles plain string literals, numbers, identifiers).
352 return p.parsePrimaryExpression()
353}
354
355// parseConnectByCondition parses the condition expression for CONNECT BY.
356// It handles the PRIOR prefix operator in either position:

Callers 1

Calls 4

advanceMethod · 0.95
isStringLiteralMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected