mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#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:
@@ -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)");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user