mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1126 - Regression bug in 10.4.5 with new line character use with SqlQuery, SqlUpdate and CallableSql
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package io.ebeaninternal.server.persist;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TrimLogSqlTest {
|
||||
|
||||
@Test
|
||||
public void trim() throws Exception {
|
||||
|
||||
assertThat(TrimLogSql.trim("hello")).isEqualTo("hello");
|
||||
assertThat(TrimLogSql.trim("hello\nthere")).isEqualTo("hello\\n there");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,32 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SqlQueryTests extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void newline_replacedInLogsOnly() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
String sql = "select * -- \n from o_customer";
|
||||
SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
|
||||
|
||||
List<SqlRow> list = sqlQuery.findList();
|
||||
assertThat(list).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newLineLiteral_replacedInLogsOnly() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
String sql = "select 'hello\nthere' as hello from o_customer";
|
||||
SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
|
||||
|
||||
List<SqlRow> list = sqlQuery.findList();
|
||||
assertThat(list).isNotEmpty();
|
||||
|
||||
assertThat(list.get(0).getString("hello")).isEqualTo("hello\nthere");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void firstRowMaxRows() {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TestSqlUpdateInTxn extends BaseTestCase {
|
||||
String sql = " this\nis\ntrimmed ";
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
assertThat(sqlUpdate.getSql()).isEqualTo("this is trimmed");
|
||||
assertThat(sqlUpdate.getSql()).isEqualTo(sql.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -28,8 +28,8 @@ public class TestSqlUpdateInTxn extends BaseTestCase {
|
||||
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");
|
||||
assertThat(sqlUpdate.getSql()).isEqualTo(sql.trim());
|
||||
assertThat(sqlUpdate.getGeneratedSql()).isEqualTo(sql.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user