Skip to content

Commit

Permalink
Fix OracleSelectTest57.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengguanLi committed Nov 26, 2024
1 parent 0d41106 commit 6e4904e
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@

public class OracleSelectTest57 extends OracleTest {
public void test_0() throws Exception {
String sql = //
"SELECT TRIM(BOTH FROM EUCD) AS \"value\",NTLANG1 AS \"text\" " //
String sql = "SELECT TRIM(BOTH FROM EUCD) AS \"value\",NTLANG1 AS \"text\" "
+ " FROM T_HT_WREM_ENUMLANG_D"
+ " WHERE TYPE=?"
+ " ORDER BY \"value\" ASC"; //
+ " ORDER BY \"value\" ASC";

OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
Expand All @@ -49,8 +48,7 @@ public void test_0() throws Exception {
System.out.println("orderBy : " + visitor.getOrderByColumns());

Assert.assertEquals(1, visitor.getTables().size());

Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertEquals(3, visitor.getColumns().size());

{
String text = SQLUtils.toOracleString(stmt);
Expand All @@ -73,4 +71,27 @@ public void test_0() throws Exception {

// Assert.assertTrue(visitor.getOrderByColumns().contains(new TableStat.Column("employees", "last_name")));
}

public void test_1() throws Exception {
String sql = "SELECT TRIM(BOTH 'x' FROM 'xJohnxx') FROM dual";

OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);

Assert.assertEquals(1, statementList.size());

OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
stmt.accept(visitor);

System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());

Assert.assertEquals(0, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
}
}

0 comments on commit 6e4904e

Please sign in to comment.