calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject calcite git commit: [CALCITE-1113] Test for precision and scale in column metadata
Date Mon, 04 Apr 2016 19:03:29 GMT
Repository: calcite
Updated Branches:
  refs/heads/master 032e0d9a5 -> ea71f9295


[CALCITE-1113] Test for precision and scale in column metadata


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/ea71f929
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/ea71f929
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/ea71f929

Branch: refs/heads/master
Commit: ea71f9295ae3bed9b88046f9a9e426bcc93a0005
Parents: 032e0d9
Author: Josh Elser <elserj@apache.org>
Authored: Mon Apr 4 14:47:30 2016 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Apr 4 15:00:13 2016 -0400

----------------------------------------------------------------------
 .../calcite/avatica/RemoteDriverTest.java       | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/ea71f929/avatica/server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
----------------------------------------------------------------------
diff --git a/avatica/server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
b/avatica/server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
index c32a54c..191802c 100644
--- a/avatica/server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
+++ b/avatica/server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
@@ -1608,6 +1608,44 @@ public class RemoteDriverTest {
     }
   }
 
+  @Test public void testDecimalParameters() throws Exception {
+    final String tableName = "decimalParameters";
+    BigDecimal decimal = new BigDecimal("123451234512345");
+    try (Connection conn = getLocalConnection();
+        Statement stmt = conn.createStatement()) {
+      assertFalse(stmt.execute("DROP TABLE IF EXISTS " + tableName));
+      String sql = "CREATE TABLE " + tableName + " (keycolumn VARCHAR(5), column1 DECIMAL(15,0))";
+      assertFalse(stmt.execute(sql));
+
+      getRequestInspection().getRequestLogger().enableAndClear();
+      // Insert a single decimal
+      try (PreparedStatement pstmt = conn.prepareStatement("INSERT INTO " + tableName
+          + " values (?, ?)")) {
+        ParameterMetaData metadata = pstmt.getParameterMetaData();
+        assertNotNull(metadata);
+        assertEquals(5, metadata.getPrecision(1));
+        assertEquals(0, metadata.getScale(1));
+        assertEquals(15, metadata.getPrecision(2));
+        assertEquals(0, metadata.getScale(2));
+
+        pstmt.setString(1, "asdfg");
+        pstmt.setBigDecimal(2, decimal);
+        assertEquals(1, pstmt.executeUpdate());
+      }
+
+      ResultSet results = stmt.executeQuery("SELECT * FROM " + tableName);
+      assertNotNull(results);
+      assertTrue(results.next());
+      BigDecimal actualDecimal = results.getBigDecimal(2);
+      assertEquals(decimal, actualDecimal);
+
+      ResultSetMetaData resultMetadata = results.getMetaData();
+      assertNotNull(resultMetadata);
+      assertEquals(15, resultMetadata.getPrecision(2));
+      assertEquals(0, resultMetadata.getScale(2));
+    }
+  }
+
   /**
    * Factory that creates a service based on a local JDBC connection.
    */


Mime
View raw message