Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-08 14:46:22 +0000
committerEike Stepper2008-10-08 14:46:22 +0000
commit4415f32f85807848edd71d4cdd61948336251ee1 (patch)
tree1680e3b95b2c361966e3836dd7d0588be1d89ef3 /plugins/org.eclipse.net4j.db.tests
parented575c08bf9aaa9096fb08fddf8eff1f2c991f0b (diff)
downloadcdo-4415f32f85807848edd71d4cdd61948336251ee1.tar.gz
cdo-4415f32f85807848edd71d4cdd61948336251ee1.tar.xz
cdo-4415f32f85807848edd71d4cdd61948336251ee1.zip
[225125] [DB] Quotes are not escaped (enough)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=225125
Diffstat (limited to 'plugins/org.eclipse.net4j.db.tests')
-rw-r--r--plugins/org.eclipse.net4j.db.tests/src/org/eclipse/net4j/db/tests/AbstractDBTest.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/org.eclipse.net4j.db.tests/src/org/eclipse/net4j/db/tests/AbstractDBTest.java b/plugins/org.eclipse.net4j.db.tests/src/org/eclipse/net4j/db/tests/AbstractDBTest.java
index d3ed4b8857..807a50a490 100644
--- a/plugins/org.eclipse.net4j.db.tests/src/org/eclipse/net4j/db/tests/AbstractDBTest.java
+++ b/plugins/org.eclipse.net4j.db.tests/src/org/eclipse/net4j/db/tests/AbstractDBTest.java
@@ -99,12 +99,29 @@ public abstract class AbstractDBTest<DATA_SOURCE extends DataSource> extends Abs
{
IDBSchema schema = DBUtil.createSchema("testEscapeStrings");
IDBTable table = schema.addTable("testtable");
- IDBField strval = table.addField("strval", DBType.VARCHAR, 255);
+ IDBField field = table.addField("strval", DBType.VARCHAR, 255);
schema.create(dbAdapter, dbConnectionProvider);
- String val = "My name is 'nobody', not body";
- DBUtil.insertRow(getConnection(), dbAdapter, table, val);
- Object[] result = DBUtil.select(getConnection(), (String)null, strval);
- assertEquals(val, result[0]);
+ insertString(field, "My name is 'nobody', not body");
+ insertString(field, "a = 'hello'");
+ insertString(field, "'hello' == a");
+ insertString(field, "'hello'");
+ }
+
+ private void insertString(IDBField field, String val)
+ {
+ Connection connection = getConnection();
+ IDBTable table = field.getTable();
+
+ try
+ {
+ DBUtil.insertRow(connection, dbAdapter, table, val);
+ Object[] result = DBUtil.select(connection, (String)null, field);
+ assertEquals(val, result[0]);
+ }
+ finally
+ {
+ DBUtil.update(connection, "DELETE FROM " + table);
+ }
}
}

Back to the top