Database Independence: Problem with Conversion of SQL Statements with Quoted Strings
| Short Description | State |
|---|---|
|
Quoted Strings in SQL statemens might get converted unintentionally |
Resolved |
| Target Database Type | Release |
|
Any, except for Oracle |
erbox_253b-* |
| Class | Methods |
|
Convert |
convertStatement(...), replaceStrings(...), recoverStrings(...) |
| Description | |
|
There is an unresolved flaw in Compiere's database independence approach, at least until release 2.5.3b: The conversion from an Oracle style SQL statement into an equivalent statement for the selected target database is done partly by a few "simple" search and replace operations with regular expressions, which are bundled in class ConvertMap. The problem is that quoted strings in SQL statements are not excluded from these search and replace operations, which leads to unintended side effects and errors. E.g. for Sybase the regex \\bSTART WITH\\b gets replaced by the string START. Any user who ever enters the string sequence START WITH in one of text fields (e.g. Product Description) on an update operation will be astonished to see, that his ERP system chooses to know better and stores START in the database instead. |
|
| Solution | |
|
The high level descriptin of the solution can be explained in three steps:
The actually implemented algorithm in Convert.replaceStrings(...) and Convert.recoverStrings(...) is more complex because finding suitable replacement strings is not trivial. It is achieved by generating a random string of growing length until the random string cannot be found in the statement to be converted. This is repeated until all quoted strings are stripped from the original statement. |
|

