* [ 1662983 ] Convert cutting backslash from string
- Fixed escape issue.
This commit is contained in:
parent
19ee138849
commit
6beb43bdde
|
@ -192,6 +192,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
for (int cont = 0; cont < retVars.size(); cont++) {
|
for (int cont = 0; cont < retVars.size(); cont++) {
|
||||||
//hengsin, special character in replacement can cause exception
|
//hengsin, special character in replacement can cause exception
|
||||||
String replacement = (String) retVars.get(cont);
|
String replacement = (String) retVars.get(cont);
|
||||||
|
replacement = escapeBackSlash(replacement);
|
||||||
retValue = m.replaceFirst(Matcher.quoteReplacement(replacement));
|
retValue = m.replaceFirst(Matcher.quoteReplacement(replacement));
|
||||||
if (retValue.indexOf(replacement) < 0)
|
if (retValue.indexOf(replacement) < 0)
|
||||||
System.err.println("Failed to recover: " + replacement);
|
System.err.println("Failed to recover: " + replacement);
|
||||||
|
@ -200,6 +201,30 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String escapeBackSlash(String in)
|
||||||
|
{
|
||||||
|
StringBuffer out = new StringBuffer();
|
||||||
|
boolean escape = false;
|
||||||
|
int size = in.length();
|
||||||
|
for(int i = 0; i < size; i++) {
|
||||||
|
char c = in.charAt(i);
|
||||||
|
out.append(c);
|
||||||
|
if (c == '\\')
|
||||||
|
{
|
||||||
|
escape = true;
|
||||||
|
out.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (escape)
|
||||||
|
{
|
||||||
|
return "E" + out.toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up Statement. Remove all comments and while spaces Database
|
* Clean up Statement. Remove all comments and while spaces Database
|
||||||
* specific functionality can me tagged as follows:
|
* specific functionality can me tagged as follows:
|
||||||
|
|
|
@ -30,7 +30,12 @@ public final class Convert_PostgreSQLTest {
|
||||||
|
|
||||||
//[ 1662983 ] Convert cutting backslash from string
|
//[ 1662983 ] Convert cutting backslash from string
|
||||||
sql = "SELECT 'C:\\Documentos\\Test' FROM DUAL";
|
sql = "SELECT 'C:\\Documentos\\Test' FROM DUAL";
|
||||||
sqe = "SELECT 'C:\\Documentos\\Test'";
|
sqe = "SELECT E'C:\\\\Documentos\\\\Test'";
|
||||||
|
r = convert.convert(sql);
|
||||||
|
verify(sql, r, sqe);
|
||||||
|
|
||||||
|
sql = "SELECT 'C:Document' FROM DUAL";
|
||||||
|
sqe = "SELECT 'C:Document'";
|
||||||
r = convert.convert(sql);
|
r = convert.convert(sql);
|
||||||
verify(sql, r, sqe);
|
verify(sql, r, sqe);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue