public virtual void testRemoveTableAndAddJoinClause() { parser.sqltext = "SELECT * FROM t1,t2 where t1.f1=t2.f2"; Assert.IsTrue(parser.parse() == 0); TSelectSqlStatement select = (TSelectSqlStatement)parser.sqlstatements.get(0); TJoinList joinList = select.joins; // let's remove t2 and where clause joinList.removeJoin(1); TJoinItem joinItem = new TJoinItem(); joinList.getJoin(0).JoinItems.addJoinItem(joinItem); joinItem.JoinType = EJoinType.left; TTable joinTable = new TTable(); joinItem.Table = joinTable; joinTable.TableName = parser.parseObjectName("t2"); joinItem.OnCondition = parser.parseExpression("t1.f1=t2.f2"); // remove where clause select.WhereClause = null; // System.out.println(scriptGenerator.generateScript(select,true)); Assert.IsTrue(testScriptGenerator.verifyScript(EDbVendor.dbvoracle , select.ToScript() , "SELECT *\n" + "FROM t1\n" + " LEFT JOIN t2\n" + " ON t1.f1 = t2.f2" )); }
public virtual void testRemoveTableInFromClauseAndRemoveWhereClause() { parser.sqltext = "SELECT * FROM t1,t2 where t1.f1=t2.f2"; Assert.IsTrue(parser.parse() == 0); TSelectSqlStatement select = (TSelectSqlStatement)parser.sqlstatements.get(0); TJoinList joinList = select.joins; joinList.removeJoin(0); select.WhereClause = null; // System.out.println(scriptGenerator.generateScript(select, true)); Assert.IsTrue(testScriptGenerator.verifyScript(EDbVendor.dbvoracle , select.ToScript() , "SELECT *\n" + "FROM t2" )); }