Merged in bugfix/PMCORE-1049 (pull request #7213)

PMCORE-1049

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2020-01-16 19:12:43 +00:00
2 changed files with 17 additions and 2 deletions

View File

@@ -909,6 +909,8 @@ class PmDynaformTest extends TestCase
$sqlOriginal3 = 'DUMMY'; $sqlOriginal3 = 'DUMMY';
$sqlOriginal4 = 'SELECT U.USR_UID, U.USR_USERNAME FROM PMT_CODES C INNER JOIN USERS U ON U.USR_USERNAME = C.USR_USERNAME';
// Instance the class PmDynaform // Instance the class PmDynaform
$pmDynaform = new PmDynaform([]); $pmDynaform = new PmDynaform([]);
@@ -924,6 +926,10 @@ class PmDynaformTest extends TestCase
// Test another string, shoul be return the same value // Test another string, shoul be return the same value
$sqlParsed3 = $pmDynaform->sqlParse($sqlOriginal3); $sqlParsed3 = $pmDynaform->sqlParse($sqlOriginal3);
$this->assertEquals($sqlOriginal3, $sqlParsed3); $this->assertEquals($sqlOriginal3, $sqlParsed3);
// Test bug PMCORE-1049
$sqlParsed4 = $pmDynaform->sqlParse($sqlOriginal4);
$this->assertNotFalse(strpos($sqlParsed4, 'C.USR_USERNAME'));
} }
/** /**

View File

@@ -1023,8 +1023,17 @@ class PmDynaform
. " JOIN " . " JOIN "
. $dt[$key]["table"] . $dt[$key]["table"]
. ($dt[$key]["table"] == $dt[$key]["alias"] ? "" : " " . $dt[$key]["alias"]) . " " . ($dt[$key]["table"] == $dt[$key]["alias"] ? "" : " " . $dt[$key]["alias"]) . " "
. $dt[$key]["ref_type"] . " " . $dt[$key]["ref_type"] . " ";
. rtrim($dt[$key]["ref_clause"], " INNER");
// Get the last 6 chars of the string
$tempString = mb_substr($dt[$key]["ref_clause"], -6);
// If the last section is a "INNER" statement we need to remove it
if (strcasecmp($tempString, " INNER") === 0) {
$from .= mb_substr($dt[$key]["ref_clause"], 0, mb_strlen($dt[$key]["ref_clause"]) - 6);
} else {
$from .= $dt[$key]["ref_clause"];
}
} }
} }
} }