details: https://code.openbravo.com/erp/devel/pi/rev/5ba902b0d15e
changeset: 13156:5ba902b0d15e
user: Stefan Hühner <stefan.huehner <at> openbravo.com>
date: Thu Jul 14 16:12:08 2011 +0200
summary: Fixed 11572: Allow «» also as separators when searching for
constraint name
Spanish translation of pgsql error messages uses «» instead of "" as quotes
around the columnname. Add that case to error text parser for postgres to be
able to find the constraint name and show a nicer error message. Also add
unit test for this. As language config of db is normally not in spanish that
added test just passes in known string into errror text-parser and does not
really test db-action vs. expected message like the other testcases.
diffstat:
src-test/org/openbravo/test/system/ErrorTextParserTest.java | 25
++++++++++
src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java | 6 ++-
2 files changed, 30 insertions(+), 1 deletions(-)
diffs (64 lines):
diff -r 96cf2a09397d -r 5ba902b0d15e
src-test/org/openbravo/test/system/ErrorTextParserTest.java
--- a/src-test/org/openbravo/test/system/ErrorTextParserTest.java Thu Jul
14 14:12:30 2011 +0200
+++ b/src-test/org/openbravo/test/system/ErrorTextParserTest.java Thu Jul
14 16:12:08 2011 +0200
@@ -72,6 +72,13 @@
doErrorTextParserTest(8);
}
+ public void testPGSpanish() throws Exception {
+ // only test on pgsql, as specifically testing against es_ES/pgsql error
messsage
+ if (getConnectionProvider().getRDBMS().equals("POSTGRE")) {
+ doErrorTextParserTestWithoutDB(1);
+ }
+ }
+
private void doErrorTextParserTest(int testCase) throws Exception {
ConnectionProvider conn = getConnectionProvider();
VariablesSecureApp vars = new VariablesSecureApp("", "", "");
@@ -129,4 +136,22 @@
assertEquals(expectedErrorMessage, trlError.getMessage());
}
+ private void doErrorTextParserTestWithoutDB(int testCase) throws Exception {
+ String errorMessage = "";
+ String expectedMessage = "";
+ ConnectionProvider conn = getConnectionProvider();
+ VariablesSecureApp vars = new VariablesSecureApp("", "", "");
+
+ switch (testCase) {
+ case 1:
+ expectedMessage = "This record cannot be deleted because it is
associated with other existing elements. Please see Linked Items";
+ errorMessage = "inserción o actualización en la tabla «c_bpartner» viola
la llave foránea «c_bpartner_c_bp_group»";
+ break;
+ }
+
+ OBError trlError = Utility.translateError(conn, vars, "en_US",
errorMessage);
+ assertEquals(expectedMessage, trlError.getMessage());
+
+ }
+
}
\ No newline at end of file
diff -r 96cf2a09397d -r 5ba902b0d15e
src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java
--- a/src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java Thu Jul
14 14:12:30 2011 +0200
+++ b/src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java Thu Jul
14 16:12:08 2011 +0200
@@ -35,6 +35,10 @@
// ERROR: insert or update on table "ad_attachment" violates foreign key
constraint "addatatype_adattachment"
// DETAIL: Key (ad_datatype_id)=() is not present in table "ad_datatype".
+// example for foreign key violation (with postgres using es_ES for error
messages)
+// ERROR: inserción o actualización en la tabla «c_bpartner» viola la llave
foránea «c_bpartner_c_bp_group»
+// DETAIL: La llave (c_bp_group_id)=(invalid) no está presente en la tabla
«c_bp_group».
+
// example for not null
// ERROR: null value in column "ad_org_id" violates not-null constraint
@@ -77,7 +81,7 @@
*/
private static String findConstraintName(String input) {
log4j.debug("find constraint name in : " + input);
- Pattern p = Pattern.compile("\".+?\"");
+ Pattern p = Pattern.compile("\".+?\"|«.+?»");
Matcher m = p.matcher(input);
if (!m.find()) {
log4j.info("did not find constraint name for error message: " + input);
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric
Ries, the creator of the Lean Startup Methodology on "Lean Startup
Secrets Revealed." This video shows you how to validate your ideas,
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits