mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix when json/jackson bean inserted as null and not changed
Expectation is that it is not included in update (still null, no change)
This commit is contained in:
@@ -10,6 +10,31 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestJacksonPlainBean {
|
||||
|
||||
@Test
|
||||
public void insertNullStayNull() {
|
||||
|
||||
// insert with jackson beans as null
|
||||
EBasicPlain bean = new EBasicPlain();
|
||||
bean.setAttr("n0");
|
||||
DB.save(bean);
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
bean.setAttr("n1");
|
||||
DB.save(bean);
|
||||
expectedSql(0, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
||||
|
||||
bean.setPlainBean(new PlainBean("x", 1));
|
||||
DB.save(bean);
|
||||
expectedSql(0, "update ebasic_plain set plain_bean=?, version=? where id=? and version=?");
|
||||
|
||||
final EBasicPlain found = DB.find(EBasicPlain.class, bean.getId());
|
||||
found.setAttr("n2");
|
||||
DB.save(found);
|
||||
expectedSql(1, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
||||
|
||||
LoggedSqlCollector.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertUpdate() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user