#1115 - Trim SQL for SqlUpdate, SqlQuery and CallableSql - also replace \n with space

This commit is contained in:
rob bygrave
2017-09-08 23:45:28 +12:00
parent 8c0232fdb8
commit 06f3c000f5
2 changed files with 34 additions and 4 deletions
@@ -3,12 +3,35 @@ package org.tests.update;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.SqlUpdate;
import org.tests.idkeys.db.AuditLog;
import org.junit.Assert;
import org.junit.Test;
import org.tests.idkeys.db.AuditLog;
import static org.assertj.core.api.Assertions.assertThat;
public class TestSqlUpdateInTxn extends BaseTestCase {
@Test
public void testSqlTrim() {
String sql = " this\nis\ntrimmed ";
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
assertThat(sqlUpdate.getSql()).isEqualTo("this is trimmed");
}
@Test
public void testSqlUpdateWithWhitespace() {
String sql = " \nupdate audit_log \nset description = description \nwhere id = id";
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
sqlUpdate.execute();
assertThat(sqlUpdate.getSql()).isEqualTo("update audit_log set description = description where id = id");
assertThat(sqlUpdate.getGeneratedSql()).isEqualTo("update audit_log set description = description where id = id");
}
@Test
public void testBasic() {