Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,11 @@ public void visit(CreateTable createTable) {
}

@Override
public <S> Void visit(CreateView createView, S context) {
throwUnsupported(createView);
public <S> Void visit(CreateView create, S context) {
visit(create.getView(), null);
if (create.getSelect() != null) {
create.getSelect().accept((SelectVisitor<?>) this, context);
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,19 @@ public void testInsertSelect() throws Exception {
}

@Test
public void testCreateSelect() throws Exception {
public void testCreateTableSelect() throws Exception {
String sqlStr = "CREATE TABLE mytable AS SELECT mycolumn FROM mytable2";
assertThat(TablesNamesFinder.findTables(sqlStr)).containsExactlyInAnyOrder("mytable",
"mytable2");
}

@Test
public void testCreateViewSelect() throws Exception {
String sqlStr = "CREATE VIEW mytable AS SELECT mycolumn FROM mytable2";
assertThat(TablesNamesFinder.findTables(sqlStr)).containsExactlyInAnyOrder("mytable",
"mytable2");
}

@Test
public void testInsertSubSelect() throws JSQLParserException {
String sqlStr =
Expand Down
Loading