Tweak in list tests

This commit is contained in:
Travis Burtrum 2018-05-20 11:27:23 -04:00
parent 23c87a25c7
commit 6e56622ce0
2 changed files with 13 additions and 9 deletions

View File

@ -60,11 +60,11 @@ public class QueryMapperQmDao implements QmDao {
Collection<Class<?>> no = new ArrayList<Class<?>>();
for(final String connectionClassName : new String[]{
"org.apache.derby.impl.jdbc.EmbedConnection"
, "org.hsqldb.jdbc.JDBCConnection" // does not support ArrayInList but *does* support UnNestArrayInList
//, "org.hsqldb.jdbc.JDBCConnection" // does not support ArrayInList but *does* support UnNestArrayInList
, "org.sqlite.jdbc3.JDBC3Connection"
, "org.mariadb.jdbc.MariaDbConnection"
, "com.microsoft.sqlserver.jdbc.SQLServerConnection"
, "oracle.jdbc.driver.PhysicalConnection" // does not support ArrayInList but *does* support OracleArrayInList
//, "oracle.jdbc.OracleConnection" // does not support ArrayInList but *does* support OracleArrayInList
// h2 doesn't support this with java6 either...
/*IFJAVA6_START
, "org.h2.jdbc.JdbcConnection"
@ -77,7 +77,7 @@ public class QueryMapperQmDao implements QmDao {
}
noArrayInListSupport = Collections.unmodifiableCollection(no);
hsqlConnection = classForName("org.hsqldb.jdbc.JDBCConnection");
oracleConnection = classForName("oracle.jdbc.driver.PhysicalConnection");
oracleConnection = classForName("oracle.jdbc.OracleConnection");
mssqlConnection = classForName("com.microsoft.sqlserver.jdbc.SQLServerConnection");
}
@ -113,12 +113,12 @@ public class QueryMapperQmDao implements QmDao {
}
public static InList getBestInList(final Connection conn) {
if(isWrapperFor(conn, oracleConnection))
return OracleArrayInList.instance();
if(isWrapperFor(conn, hsqlConnection))
return UnNestArrayInList.instance();
if(supportsArrayInList(conn))
return ArrayInList.instance();
if(isWrapperFor(conn, hsqlConnection))
return UnNestArrayInList.instance();
if(isWrapperFor(conn, oracleConnection))
return OracleArrayInList.instance();
// works for everything
return BindInList.instance();
}

View File

@ -76,7 +76,7 @@ public class QueryMapperTest {
final Collection<String> jUrls = new ArrayList<String>();
final String jdbcUrl = System.getProperty("jdbcUrl", "all");
if(jdbcUrl.equals("all")) {
jUrls.add("jdbc:hsqldb:mem:testDB");
//jUrls.add("jdbc:hsqldb:mem:testDB"); // remove this from all since it supports custom InList, until generic inlist supported in JdbcMapper
jUrls.add("jdbc:derby:memory:testDB;create=true");
jUrls.add("jdbc:h2:mem:testDB");
jUrls.add("jdbc:sqlite::memory:");
@ -521,9 +521,13 @@ public class QueryMapperTest {
assertArrayEquals(people, fromDb.toArray());
}
private static boolean supportsInList(final QmDao qm) {
return qm instanceof QueryMapperQmDao || supportsArrayInList(qm.getConnection());
}
@Test
public void testListQueryMapperList() throws SQLException {
if(!(qm instanceof QueryMapperQmDao) && !supportsArrayInList(conn))
if(!supportsInList(qm))
return;
final List<FieldPerson> fromDb = qm.getFieldPeople(Arrays.asList(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo()));
assertArrayEquals(people, fromDb.toArray());