#752 - Refactor: SQL generation for @History support with Postgres, MySql (views/triggers based) such that it more closely aligns with SQL 2011 based SQL

This commit is contained in:
Robin Bygrave
2016-06-23 11:33:01 +12:00
parent f8bda05b37
commit 2185c8a886
17 changed files with 148 additions and 103 deletions
@@ -0,0 +1,32 @@
package com.avaje.ebean.config.dbplatform;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class MySqlHistorySupportTest {
private MySqlHistorySupport support = new MySqlHistorySupport();
@Test
public void getAsOfPredicate() {
String asOfPredicate = support.getAsOfPredicate("t0", "sys_period");
assertEquals(asOfPredicate, "(t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?))");
}
@Test
public void getLower() throws Exception {
String lower = support.getSysPeriodLower("t0", "sys_period");
assertEquals(lower, "t0.sys_period_start");
}
@Test
public void getUpper() throws Exception {
String upper = support.getSysPeriodUpper("t0", "sys_period");
assertEquals(upper, "t0.sys_period_end");
}
}
@@ -0,0 +1,38 @@
package com.avaje.ebean.config.dbplatform;
import org.junit.Test;
import static org.junit.Assert.*;
public class PostgresHistorySupportTest {
private PostgresHistorySupport support = new PostgresHistorySupport();
@Test
public void getBindCount() throws Exception {
assertEquals(support.getBindCount(), 1);
}
@Test
public void getAsOfPredicate() throws Exception {
String asOfPredicate = support.getAsOfPredicate("t0", "sys_period");
assertEquals(asOfPredicate, "t0.sys_period @> ?::timestamptz");
}
@Test
public void getSysPeriodLower() throws Exception {
String lower = support.getSysPeriodLower("t0", "sys_period");
assertEquals(lower, "lower(t0.sys_period)");
}
@Test
public void getSysPeriodUpper() throws Exception {
String upper = support.getSysPeriodUpper("t0", "sys_period");
assertEquals(upper, "upper(t0.sys_period)");
}
}