bug fix [ 1652623 ] AccessSqlParser.getTableInfo(String) - tablename parsing bug

This commit is contained in:
teo_sarca 2007-02-10 16:25:46 +00:00
parent baf877e3b2
commit 7baf3f45c9
2 changed files with 21 additions and 1 deletions

View File

@ -23,6 +23,11 @@ import org.compiere.util.*;
/**
* Parse FROM in SQL WHERE clause
* <p>
* Change log:
* <ul>
* <li>2007-02-10 - teo_sarca - [ 1652623 ] AccessSqlParser.getTableInfo(String) - tablename parsing bug
* </ul>
*
* @author Jorg Janke
* @version $Id: AccessSqlParser.java,v 1.3 2006/07/30 00:58:36 jjanke Exp $
@ -250,7 +255,7 @@ public class AccessSqlParser
while (tableST.hasMoreTokens())
{
String tableString = tableST.nextToken().trim();
StringTokenizer synST = new StringTokenizer (tableString, " ");
StringTokenizer synST = new StringTokenizer (tableString, " \r\n\t"); // teo_sarca [ 1652623 ] AccessSqlParser.getTableInfo(String) - tablename parsing bug
TableInfo tableInfo = null;
if (synST.countTokens() > 1)
tableInfo = new TableInfo(synST.nextToken(), synST.nextToken());

View File

@ -208,6 +208,21 @@ public class AccessSqlParserTest extends TestCase
String sql = "SELECT XX_HTC1_EMPLOYEE_V.C_BPartner_ID,NULL,XX_HTC1_EMPLOYEE_V.C_BPARTNER_NAME,XX_HTC1_EMPLOYEE_V.IsActive FROM XX_HTC1_EMPLOYEE_V WHERE XX_HTC1_EMPLOYEE_V.AD_User_ID IN (SELECT ur.AD_User_ID FROM AD_User_Roles ur INNER JOIN AD_Role r ON (ur.AD_Role_ID=r.AD_Role_ID) WHERE r.Name like '%Field Manager%')";
AccessSqlParser fixture = new AccessSqlParser(sql);
}
/**
* teo_sarca - [ 1652623 ] AccessSqlParser.getTableInfo(String) - tablename parsing bug
*/
public void testTableNameParsing()
{
String sql =
"SELECT SUM(il.QtyInvoiced)\n"
+ "FROM RV_C_Invoice\n"
+ "C_Invoice\n"
+ "INNER JOIN RV_C_InvoiceLine il ON (C_Invoice.C_Invoice_ID=il.C_Invoice_ID) WHERE\n"
+ "C_Invoice.IsSOTrx='Y' AND C_Invoice.Processed='Y' AND C_Invoice.IsPaid='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[RV_C_Invoice=C_Invoice|0]", fixture.toString());
}
}