Skip to content

Parser fails to parse column references that include "*" #173

Open
@mbornstein

Description

@mbornstein

The following SQL cannot be parsed even though it is perfectly valid (at least in PG 17)

select "a column with *" from table

fails with:

invalid syntax at line 1 col 8:

  select "a column with *" from table;
         ^
Unexpected input (lexer error). Instead, I was expecting to see one of the following:

    - A "kw_all" token
    - A "kw_distinct" token
    - A "kw_from" token
    - A "star" token
    - A "lparen" token
    - A "kw_where" token
    - A "kw_group" token
    - A "kw_order" token
    - A "kw_for" token
    - A "kw_not" token
    - A "kw_offset" token
    - A "kw_limit" token
    - A "kw_fetch" token
    - A "kw_union" token
    - A "semicolon" token
    - A "word" token
    - A "op_plus" token
    - A "op_minus" token
    - A "kw_cast" token
    - A "kw_current_schema" token
    - A "kw_current_schema" token
    - A "kw_true" token
    - A "kw_false" token
    - A "kw_null" token
    - A "qparam" token
    - A "kw_default" token
    - A "word" token
    - A "word" token
    - A "word" token
    - A "word" token
    - A "kw_precision" token
    - A "kw_array" token
    - A "kw_array" token
    - A "kw_case" token
    - A "kw_primary" token
    - A "kw_unique" token
    - A "quoted_word" token
    - A "word" token
    - A "float" token
    - A "int" token
    - A "kw_current_catalog" token
    - A "kw_current_date" token
    - A "kw_current_role" token
    - A "kw_current_schema" token
    - A "kw_current_timestamp" token
    - A "kw_current_time" token
    - A "kw_localtimestamp" token
    - A "kw_localtime" token
    - A "kw_session_user" token
    - A "kw_user" token
    - A "kw_current_user" token
    - A "string" token
    - A "eString" token
    - A "kw_any" token
    - A "kw_some" token
    - A "kw_all" token

this is due to * being explicitely excluded in the wordQuoted regex here

wordQuoted: {
        match: /"(?:[^"\*]|"")+"/,

unsure if there is a reason for this I am not aware of or if this can just be changed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions