Skip to content

"WITH costs AS (...." causes ParseException #1185

@frsann

Description

@frsann

Describe the bug
Using the name costs in the WITH clause throws an exception

To Reproduce
This tests fails.

    @Test
    public void testGetTableListWithStmtFails() throws Exception {
        String sql = "WITH costs AS (SELECT * FROM MY_TABLE1 as ALIAS_TABLE1) SELECT * FROM TESTSTMT";
        net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));

        Select selectStatement = (Select) statement;
        TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
        List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
        assertEquals(1, tableList.size());
        assertEquals("MY_TABLE1", tableList.get(0));
    }

Expected behavior
The test should not fail.

System

  • Database you are using: Not relevant.
  • Java Version: openjdk version "1.8.0_232"
  • JSqlParser version: 4.1

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