@@ -188,6 +188,17 @@ public void testGetTableListFromInsert() throws Exception {
188188 assertTrue (tableList .contains ("MY_TABLE1" ));
189189 assertTrue (tableList .contains ("MY_TABLE2" ));
190190 }
191+
192+ public void testGetTableListFromInsertValues () throws Exception {
193+ String sql = "INSERT INTO MY_TABLE1 (a) VALUES (5)" ;
194+ net .sf .jsqlparser .statement .Statement statement = pm .parse (new StringReader (sql ));
195+
196+ Insert insertStatement = (Insert ) statement ;
197+ TablesNamesFinder tablesNamesFinder = new TablesNamesFinder ();
198+ List <String > tableList = tablesNamesFinder .getTableList (insertStatement );
199+ assertEquals (1 , tableList .size ());
200+ assertTrue (tableList .contains ("MY_TABLE1" ));
201+ }
191202
192203 public void testGetTableListFromReplace () throws Exception {
193204 String sql = "REPLACE INTO MY_TABLE1 (a) VALUES ((SELECT a from MY_TABLE2 WHERE a = 1))" ;
@@ -212,6 +223,18 @@ public void testGetTableListFromUpdate() throws Exception {
212223 assertTrue (tableList .contains ("MY_TABLE1" ));
213224 assertTrue (tableList .contains ("MY_TABLE2" ));
214225 }
226+
227+ public void testGetTableListFromUpdate2 () throws Exception {
228+ String sql = "UPDATE MY_TABLE1 SET a = 5 WHERE 0 < (SELECT COUNT(b) FROM MY_TABLE3)" ;
229+ net .sf .jsqlparser .statement .Statement statement = pm .parse (new StringReader (sql ));
230+
231+ Update updateStatement = (Update ) statement ;
232+ TablesNamesFinder tablesNamesFinder = new TablesNamesFinder ();
233+ List <String > tableList = tablesNamesFinder .getTableList (updateStatement );
234+ assertEquals (2 , tableList .size ());
235+ assertTrue (tableList .contains ("MY_TABLE1" ));
236+ assertTrue (tableList .contains ("MY_TABLE3" ));
237+ }
215238
216239 private String getLine (BufferedReader in ) throws Exception {
217240 return CCJSqlParserManagerTest .getLine (in );
0 commit comments