* [ 1662983 ] Convert cutting backslash from string
This commit is contained in:
parent
d198daba59
commit
646a4d07c8
|
@ -237,6 +237,7 @@ public abstract class Convert
|
|||
protected String[] convertIt (String sqlStatements)
|
||||
{
|
||||
// Need to mask / in SQL Strings !
|
||||
|
||||
final char MASK = '\u001F'; // Unit Separator
|
||||
StringBuffer masked = new StringBuffer(sqlStatements.length());
|
||||
Matcher m = Pattern.compile("'[^']+'", Pattern.DOTALL).matcher(sqlStatements);
|
||||
|
@ -247,7 +248,8 @@ public abstract class Convert
|
|||
group = group.replace('/', MASK);
|
||||
if (group.indexOf('$') != -1) // Group character needs to be escaped
|
||||
group = Util.replace(group, "$", "\\$");
|
||||
m.appendReplacement(masked, group);
|
||||
//hengsin, [ 1662983 ] Convert cutting backslash from string
|
||||
m.appendReplacement(masked, Matcher.quoteReplacement(group));
|
||||
}
|
||||
m.appendTail(masked);
|
||||
String tempResult = masked.toString();
|
||||
|
@ -261,8 +263,9 @@ public abstract class Convert
|
|||
for (int i = 0; i < sql.length; i++)
|
||||
{
|
||||
String statement = sql[i];
|
||||
/*
|
||||
if (statement.indexOf(MASK) != -1)
|
||||
statement = statement.replace(MASK, '/');
|
||||
statement = statement.replace(MASK, '/');*/
|
||||
result.addAll(convertStatement(statement)); // may return more than one target statement
|
||||
}
|
||||
// convert to array
|
||||
|
|
|
@ -193,6 +193,8 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
|||
//hengsin, special character in replacement can cause exception
|
||||
String replacement = (String) retVars.get(cont);
|
||||
retValue = m.replaceFirst(Matcher.quoteReplacement(replacement));
|
||||
if (retValue.indexOf(replacement) < 0)
|
||||
System.err.println("Failed to recover: " + replacement);
|
||||
m = p.matcher(retValue);
|
||||
}
|
||||
return retValue;
|
||||
|
|
|
@ -28,6 +28,12 @@ public final class Convert_PostgreSQLTest {
|
|||
String sqe;
|
||||
String[] r;
|
||||
|
||||
//[ 1662983 ] Convert cutting backslash from string
|
||||
sql = "SELECT 'C:\\Documentos\\Test' FROM DUAL";
|
||||
sqe = "SELECT 'C:\\Documentos\\Test'";
|
||||
r = convert.convert(sql);
|
||||
verify(sql, r, sqe);
|
||||
|
||||
// Line 407 of ImportProduct.java
|
||||
|
||||
sql = "ALTER TABLE LPI_Publication MODIFY AD_Client_ID NUMERIC(10) DEFAULT NULL";
|
||||
|
|
Loading…
Reference in New Issue