#1113 - SqlUpdate with leading spaces leads to Invalid event detection (which table was update for L2 cache invalidation etc)

This commit is contained in:
Rob Bygrave
2017-09-07 00:36:52 +12:00
parent 9b621d2ec7
commit 58eb49617b
5 changed files with 29 additions and 18 deletions
@@ -3,9 +3,13 @@ package org.tests.rawsql;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.SqlUpdate;
import io.ebean.Transaction;
import io.ebeaninternal.api.SpiTransaction;
import org.tests.idkeys.db.AuditLog;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
public class TestInsertSqlLogging extends BaseTestCase {
@Test
@@ -20,6 +24,22 @@ public class TestInsertSqlLogging extends BaseTestCase {
sqlUpdate.setParameter(3, "rob");
sqlUpdate.execute();
}
@Test
public void test_trim_leadingSpaces_eventFound() {
Transaction transaction = Ebean.beginTransaction();
try {
String upd = " update audit_log set description='junk' where id = 10001";
SqlUpdate update = Ebean.createSqlUpdate(upd);
update.execute();
transaction.commit();
assertFalse(((SpiTransaction) transaction).getEvent().getEventTables().isEmpty());
} finally {
transaction.end();
}
}
}