Skip to content

Single quoted literal with alias generates wrong tokens #518

Open

Description

@dcaballero

Using version 0.3.0

In a query such as this:

SELECT 'fixed_text' ALIAS1 FROM .......

The tokens generated are:
Token (ttype=Token.Literal.String.Single) = 'fixed_text'
Identifier = ALIAS1

The expected tokens are:
1 Identifier with tokens containing a Single and an Identifier

Expected tokens are generated correctly when the 'AS' keword is used:

SELECT 'fixed_text' AS ALIAS1 FROM .......

If there are many fields in the select list, the behavior remains, but Identifier or IdentifierList tokens are generated before and/or after the Single:

SELECT 'fixed_text' ALIAS1, field1, field2 FROM .......
Will generate 1 Single and 1 IdentifierList, the IdentifierList will contain 3 Identifiers (ALIAS1, field1 and field2)

SELECT field1, field2, 'fixed_text' ALIAS1 FROM .......
Will generate 1 IdentifierList (field1, field2, 1 Single), 1 Identifier (ALIAS1)

Activity

  1. yzjkzq commented on Jul 8, 2020

    @yzjkzq

    same as

    SELECT NULL ALIAS1, field1, field2 FROM .......

    for oracle

  2. yzjkzq commented on Jul 9, 2020

    @yzjkzq

    i made it by adding "T.String.Single" to "ttypes" of "grouping.py::group_identifier()", but no further test.

  3. BlackWatchuser commented on Jun 9, 2021

    @BlackWatchuser

    i made it by adding "T.String.Single" to "ttypes" of "grouping.py::group_identifier()", but no further test.

    i did this too, but it will take some Literal words in select (such as select "a" ...) into Identifier instead of Literal token, which seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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