mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-12-21 06:48:51 -05:00
Fix testGetGeneratedKeysSingleLong
This commit is contained in:
parent
05d6c4c4be
commit
268b0500f1
@ -468,50 +468,59 @@ public class QueryMapperTest {
|
||||
return;
|
||||
final QueryMapper qm = ((QueryMapperQmDao)this.qm).getQm();
|
||||
|
||||
// auto increment stuff for getGeneratedKeys, how obnoxious are these subtle differences...
|
||||
if(isWrapperFor(qm.getConnection(), classForName("org.sqlite.SQLiteConnection"))) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if(isWrapperFor(qm.getConnection(), classForName("org.mariadb.jdbc.MariaDbPooledConnection"))) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY AUTO_INCREMENT,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if(isWrapperFor(qm.getConnection(), postgreConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no SERIAL PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if(isWrapperFor(qm.getConnection(), mssqlConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER IDENTITY(1,1) PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if(isWrapperFor(qm.getConnection(), oracleConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
qm.executeUpdate("CREATE SEQUENCE a_thaoeu_table_seq\n" +
|
||||
"MINVALUE 1\n" +
|
||||
"START WITH 1\n" +
|
||||
"INCREMENT BY 1\n" +
|
||||
"CACHE 10");
|
||||
// so different we have to do test here
|
||||
for(long expected = 1; expected < 5; ++expected) {
|
||||
final long autoTableNo = qm.insertGetGeneratedKey("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", expected * 2);
|
||||
try {
|
||||
// auto increment stuff for getGeneratedKeys, how obnoxious are these subtle differences...
|
||||
if (isWrapperFor(qm.getConnection(), classForName("org.sqlite.SQLiteConnection"))) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if (isWrapperFor(qm.getConnection(), classForName("org.mariadb.jdbc.MariaDbPooledConnection"))) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY AUTO_INCREMENT,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if (isWrapperFor(qm.getConnection(), postgreConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no SERIAL PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if (isWrapperFor(qm.getConnection(), mssqlConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER IDENTITY(1,1) PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
} else if (isWrapperFor(qm.getConnection(), oracleConnection)) {
|
||||
qm.executeUpdate("CREATE TABLE a_thaoeu_table(\n" +
|
||||
" a_thaoeu_table_no INTEGER PRIMARY KEY,\n" +
|
||||
" a_thaoeu_table_val NUMERIC\n" +
|
||||
")");
|
||||
qm.executeUpdate("CREATE SEQUENCE a_thaoeu_table_seq\n" +
|
||||
"MINVALUE 1\n" +
|
||||
"START WITH 1\n" +
|
||||
"INCREMENT BY 1\n" +
|
||||
"CACHE 10");
|
||||
// so different we have to do test here
|
||||
for (long expected = 1; expected < 5; ++expected) {
|
||||
final long autoTableNo = qm.insertGetGeneratedKey("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", expected * 2);
|
||||
assertEquals(expected, autoTableNo);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
return; // can't do test...
|
||||
}
|
||||
|
||||
for (long expected = 1; expected < 5; ++expected) {
|
||||
final long autoTableNo = qm.insertGetGeneratedKey("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", expected * 2);
|
||||
assertEquals(expected, autoTableNo);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
return; // can't do test...
|
||||
}
|
||||
|
||||
for(long expected = 1; expected < 5; ++expected) {
|
||||
final long autoTableNo = qm.insertGetGeneratedKey("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", expected * 2);
|
||||
assertEquals(expected, autoTableNo);
|
||||
} finally {
|
||||
try {
|
||||
qm.executeUpdate("DROP TABLE a_thaoeu_table");
|
||||
qm.executeUpdate("DROP SEQUENCE a_thaoeu_table_seq");
|
||||
} catch(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user