dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00527
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 153: Fixed bug related to quoting in H2 sql grammar
------------------------------------------------------------
revno: 153
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-04-04 00:56:42 +0200
message:
Fixed bug related to quoting in H2 sql grammar
modified:
dhis-2/dhis-services/dhis-service-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java
dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
=== modified file 'dhis-2/dhis-services/dhis-service-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java'
--- dhis-2/dhis-services/dhis-service-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java 2009-03-19 15:51:25 +0000
+++ dhis-2/dhis-services/dhis-service-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java 2009-04-03 22:56:42 +0000
@@ -45,7 +45,7 @@
public class DataElementBatchHandlerTest
extends DhisConvenienceTest
{
- private HibernateCacheManager cacheManager;
+ private HibernateCacheManager cacheManager;
private BatchHandlerFactory batchHandlerFactory;
@@ -121,6 +121,17 @@
assertNotNull( dataElementService.getDataElement( idC ) );
}
+ public void testInsertWithSpecialCharacters()
+ {
+ dataElementA.setDescription( "'quote'" );
+ dataElementB.setDescription( "\\backslash\\" );
+ dataElementC.setDescription( ";semicolon;" );
+
+ batchHandler.insertObject( dataElementA, false );
+ batchHandler.insertObject( dataElementB, false );
+ batchHandler.insertObject( dataElementC, false );
+ }
+
public void testUpdateObject()
{
int id = dataElementService.addDataElement( dataElementA );
=== modified file 'dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2009-03-13 11:51:35 +0000
+++ dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2009-04-03 22:56:42 +0000
@@ -270,4 +270,22 @@
{
return 1580; // TODO verify
}
+
+ // -------------------------------------------------------------------------
+ // AbstractStatementBuilder implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ protected String sqlEncode( String string )
+ {
+ if ( string != null )
+ {
+ string = string.endsWith( "\\" ) ? string.substring( 0, string.length() - 1 ) : string;
+ string = string.replaceAll( QUOTE, QUOTE + QUOTE );
+
+ return string;
+ }
+
+ return null;
+ }
}
--
Trunk
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.