Skip to content

Fail to parse - "select * from (table_name)" #154

Description

@eyalleshem

I think it's fail here - https://github.com/andygrove/sqlparser-rs/blob/master/src/parser.rs#L1797
because the code assume that inside the Parenthesis should be TableFactor::Derived or TableFactor::NestedJoin, but it's not take in account it's could be TableFactor::Table

Activity

  1. nickolay commented on Mar 31, 2020

    @nickolay
    Contributor

    from (table_name) is not actually valid SQL. Note that <table primary> in the ANSI SQL grammar does not allow parentheses around <table or query name>. A quick test shows that at least MS SQL Server follows the spec here. What database are you working with?

  2. eyalleshem commented on Mar 31, 2020

    @eyalleshem
    ContributorAuthor

    Thanks for the fast response :)

    I tested against snowflake ..
    Is that something that could be solve by building a dialect ?

  3. nickolay commented on Mar 31, 2020

    @nickolay
    Contributor

    Theoretically, yes. Practically in the current implementation the selected dialect only affects the tokenizer, and the parser unconditionally tries to parse some non-standard constructs.

  4. eyalleshem commented on Mar 31, 2020

    @eyalleshem
    ContributorAuthor

    So a code that support such syntax could be accepted?

  5. nickolay commented on Mar 31, 2020

    @nickolay
    Contributor

    I guess so, if it's going to be a simple change, that doesn't introduce problems parsing the standard syntax (this specific bit of the parser is quite complex as it is). @benesch what do you think?

  6. eyalleshem commented on Mar 31, 2020

    @eyalleshem
    ContributorAuthor

    well - i tried :)

  7. nickolay commented on Apr 21, 2020

    @nickolay
    Contributor

    PR #155 is now merged, closing this. Thanks!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions