[ 3137355 ] PG query not valid when contains quotes and backslashes

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3137355
This commit is contained in:
teo_sarca 2011-03-26 00:20:20 -05:00
parent f12e817fd3
commit ecd3d5f8e2
2 changed files with 9 additions and 1 deletions

View File

@ -310,7 +310,9 @@ public abstract class Convert
i++;
}
m.appendTail(retValue);
return retValue.toString();
return retValue.toString()
.replace(quoteMarker, "''") // Put back quotes, if any
;
}
/**

View File

@ -483,5 +483,11 @@ public final class Convert_PostgreSQLTest extends TestCase{
sqe = "INSERT INTO MyTable (a, b, c, d, xml) VALUES ('val1', 'val2', E'this ''is'' a string with ''quotes'' and backslashes ''\\\\''', 'val4')";
r = convert.convert(sql);
assertEquals(sqe, r[0]);
sql = "SELECT AD_Tab.AD_Tab_ID,NULL,COALESCE(AD_Tab.Name,'-1') ||'_'|| COALESCE((SELECT COALESCE(AD_Window.Name,'') FROM AD_Window WHERE AD_Tab.AD_Window_ID=AD_Window.AD_Window_ID),'-1'),AD_Tab.IsActive"
+" FROM AD_Tab WHERE AD_Tab.AD_Tab_ID=?";
sqe = sql;
r = convert.convert(sql);
assertEquals(sqe, r[0]);
}
}