Skip to content
Permalink
Browse files

Fix execution with big decimal in simple query mode. (#1463)

  • Loading branch information...
kaiwangchen authored and davecramer committed Apr 9, 2019
1 parent b6ab27c commit 8e47a303a6e89de43bd6983f92f04f3591a385d9
@@ -250,6 +250,8 @@ public String toString(int index, boolean standardConformingStrings) {
p.append("::date");
} else if (paramType == Oid.INTERVAL) {
p.append("::interval");
} else if (paramType == Oid.NUMERIC) {
p.append("::numeric");
}
return p.toString();
}
@@ -5,20 +5,26 @@

package org.postgresql.test.jdbc42;

import org.postgresql.PGProperty;
import org.postgresql.test.TestUtil;
import org.postgresql.test.jdbc2.BaseTest4;

import org.junit.Assert;
import org.junit.Test;

import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.LocalTime;
import java.util.Properties;


public class PreparedStatementTest extends BaseTest4 {
protected void updateProperties(Properties props) {
PGProperty.PREFER_QUERY_MODE.set(props, "simple");
}

@Override
public void setUp() throws Exception {
@@ -36,6 +42,19 @@ public void tearDown() throws SQLException {
super.tearDown();
}

@Test
public void testSetNumber() throws SQLException {
PreparedStatement pstmt = con.prepareStatement("SELECT ? * 2");

pstmt.setBigDecimal(1, new BigDecimal("1.6"));
ResultSet rs = pstmt.executeQuery();
rs.next();
BigDecimal d = rs.getBigDecimal(1);
pstmt.close();

Assert.assertEquals(new BigDecimal("3.2"), d);
}

@Test
public void testTimestampTzSetNull() throws SQLException {
PreparedStatement pstmt = con.prepareStatement("INSERT INTO timestamptztable (tstz) VALUES (?)");

0 comments on commit 8e47a30

Please sign in to comment.
You can’t perform that action at this time.