Permalink
Browse files

test: fix StringTypeParameterTest to skip preferQueryMode=simple

Simple query mode does not send data type over the wire, so errors like
"column \"m\" is of type mood but expression is of type character varying" never happen
  • Loading branch information...
vlsi committed Jul 23, 2017
1 parent 8afe856 commit beca16922b455a6a00c655df8a3b701d008aad6e
Showing with 6 additions and 10 deletions.
  1. +6 −10 pgjdbc/src/test/java/org/postgresql/test/jdbc3/StringTypeParameterTest.java
@@ -9,7 +9,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.postgresql.core.ServerVersion;
import org.postgresql.jdbc.PreferQueryMode;
import org.postgresql.test.TestUtil;
import org.postgresql.test.jdbc2.BaseTest4;
import org.postgresql.util.PSQLState;
@@ -71,7 +71,7 @@ public void tearDown() throws SQLException {
@Test
public void testVarcharAsEnum() throws Exception {
Assume.assumeFalse(UNSPECIFIED_STRING_TYPE.equals(stringType));
boolean v90 = TestUtil.haveMinimumServerVersion(con, ServerVersion.v9_0);
Assume.assumeTrue(preferQueryMode != PreferQueryMode.SIMPLE);
PreparedStatement update = con.prepareStatement("insert into stringtypetest (m) values (?)");
for (int i = 0; i < 2; i++) {
@@ -83,10 +83,8 @@ public void testVarcharAsEnum() throws Exception {
}
try {
update.executeUpdate();
if (v90) {
fail("Expected 'column \"m\" is of type mood but expression is of type character varying', "
+ (i == 0 ? "setString(1, \"sad\")" : "setObject(1, \"sad\", Types.VARCHAR)"));
}
fail("Expected 'column \"m\" is of type mood but expression is of type character varying', "
+ (i == 0 ? "setString(1, \"sad\")" : "setObject(1, \"sad\", Types.VARCHAR)"));
} catch (SQLException e) {
// Exception exception is
// ERROR: column "m" is of type mood but expression is of type character varying
@@ -110,17 +108,15 @@ public void testOtherAsEnum() throws Exception {
@Test
public void testMultipleEnumBinds() throws Exception {
Assume.assumeFalse(UNSPECIFIED_STRING_TYPE.equals(stringType));
boolean v90 = TestUtil.haveMinimumServerVersion(con, ServerVersion.v9_0);
Assume.assumeTrue(preferQueryMode != PreferQueryMode.SIMPLE);
PreparedStatement query =
con.prepareStatement("select * from stringtypetest where m = ? or m = ?");
query.setString(1, "sad");
query.setObject(2, "sad", Types.VARCHAR);
try {
query.executeQuery();
if (v90) {
fail("Expected 'operator does not exist: mood = character varying'");
}
fail("Expected 'operator does not exist: mood = character varying'");
} catch (SQLException e) {
// Exception exception is
// ERROR: operator does not exist: mood = character varying

0 comments on commit beca169

Please sign in to comment.