Skip to content

Query with missing semi-colon gets wrongfully parsed #113

@proddata

Description

@proddata

The following 4 statements

select 1;
select 1 I can put anything here
select 3

... get parsed into 2 seemly valid statements ...

[
  Statement {
    query: 'select 1',
    originalQuery: 'select 1;\nselect 1 I can put anything here\nselect 3;',
    tree: '(statement (query (queryNoWith (queryTerm (querySpec select (selectItem (expr (booleanExpression (predicated (valueExpression (primaryExpression (parameterOrLiteral (parameterOrSimpleLiteral (numericLiteral (integerLiteral 1)))))))))))))))',
    type: 'select',
    ctx: DefaultContext {
      parentCtx: [StatementsContext],
      invokingState: 250,
      children: [Array],
      start: [Pt],
      stop: [Pt],
      exception: null,
      parser: [_SqlBaseParser],
      ruleIndex: 3
    },
    exception: null,
    metadata: Metadata {
      tables: [],
      parameterizedProperties: {},
      withProperties: {}
    }
  },
  Statement {
    query: 'select 1 I',
    originalQuery: 'select 1;\nselect 1 I can put anything here\nselect 3;',
    tree: '(statement (query (queryNoWith (queryTerm (querySpec select (selectItem (expr (booleanExpression (predicated (valueExpression (primaryExpression (parameterOrLiteral (parameterOrSimpleLiteral (numericLiteral (integerLiteral 1))))))))) (ident (unquotedIdent I))))))))',
    type: 'select',
    ctx: DefaultContext {
      parentCtx: [StatementsContext],
      invokingState: 252,
      children: [Array],
      start: [Pt],
      stop: [Pt],
      exception: null,
      parser: [_SqlBaseParser],
      ruleIndex: 3
    },
    exception: null,
    metadata: Metadata {
      tables: [],
      parameterizedProperties: {},
      withProperties: {}
    }
  }
]

... ignoring the missing semicolon ; and dropping the select 2; query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions