@@ -96,6 +96,8 @@ public void insertTestData() {
9696 .to (new BigDecimal ("3.14" ))
9797 .set ("col_timestamptz" )
9898 .to (Timestamp .parseTimestamp ("2022-01-27T17:51:30+01:00" ))
99+ .set ("col_interval" )
100+ .to ("P1Y2M3DT4H5M6" )
99101 .set ("col_date" )
100102 .to (com .google .cloud .Date .parseDate ("2022-04-29" ))
101103 .set ("col_varchar" )
@@ -153,7 +155,7 @@ public void testParameterMetaData() throws SQLException {
153155 for (String sql :
154156 new String [] {
155157 "select col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
156- + "col_timestamptz, col_date, col_varchar, col_jsonb "
158+ + "col_timestamptz, col_interval, col_date, col_varchar, col_jsonb "
157159 + "from all_types "
158160 + "where col_bigint=? "
159161 + "and col_bool=? "
@@ -163,18 +165,19 @@ public void testParameterMetaData() throws SQLException {
163165 + "and col_int=? "
164166 + "and col_numeric=? "
165167 + "and col_timestamptz=? "
168+ + "and col_interval=? "
166169 + "and col_date=? "
167170 + "and col_varchar=? "
168171 + "and col_jsonb::text=?" ,
169172 "insert into all_types "
170173 + "(col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
171- + "col_timestamptz, col_date, col_varchar, col_jsonb) "
172- + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
174+ + "col_timestamptz, coL_interval, col_date, col_varchar, col_jsonb) "
175+ + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ,
173176 "insert into all_types "
174177 + "(col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
175- + "col_timestamptz, col_date, col_varchar, col_jsonb) "
178+ + "col_timestamptz, col_interval, col_date, col_varchar, col_jsonb) "
176179 + "select col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
177- + "col_timestamptz, col_date, col_varchar, col_jsonb "
180+ + "col_timestamptz, col_interval, col_date, col_varchar, col_jsonb "
178181 + "from all_types "
179182 + "where col_bigint=? "
180183 + "and col_bool=? "
@@ -184,13 +187,14 @@ public void testParameterMetaData() throws SQLException {
184187 + "and col_int=? "
185188 + "and col_numeric=? "
186189 + "and col_timestamptz=? "
190+ + "and col_interval=? "
187191 + "and col_date=? "
188192 + "and col_varchar=? "
189193 + "and col_jsonb::text=?" ,
190- "insert into all_types " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
194+ "insert into all_types " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ,
191195 "insert into all_types "
192196 + "select col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
193- + "col_timestamptz, col_date, col_varchar, col_jsonb "
197+ + "col_timestamptz, col_interval, col_date, col_varchar, col_jsonb "
194198 + "from all_types "
195199 + "where col_bigint=? "
196200 + "and col_bool=? "
@@ -200,6 +204,7 @@ public void testParameterMetaData() throws SQLException {
200204 + "and col_int=? "
201205 + "and col_numeric=? "
202206 + "and col_timestamptz=? "
207+ + "and col_interval=? "
203208 + "and col_date=? "
204209 + "and col_varchar=? "
205210 + "and col_jsonb::text=?" ,
@@ -211,6 +216,7 @@ public void testParameterMetaData() throws SQLException {
211216 + "col_int=?, "
212217 + "col_numeric=?, "
213218 + "col_timestamptz=?, "
219+ + "col_interval=?, "
214220 + "col_date=?, "
215221 + "col_varchar=?, "
216222 + "col_jsonb=?" ,
@@ -222,6 +228,7 @@ public void testParameterMetaData() throws SQLException {
222228 + "col_int=null, "
223229 + "col_numeric=null, "
224230 + "col_timestamptz=null, "
231+ + "col_interval=null, "
225232 + "col_date=null, "
226233 + "col_varchar=null, "
227234 + "col_jsonb=null "
@@ -233,6 +240,7 @@ public void testParameterMetaData() throws SQLException {
233240 + "and col_int=? "
234241 + "and col_numeric=? "
235242 + "and col_timestamptz=? "
243+ + "and col_interval=? "
236244 + "and col_date=? "
237245 + "and col_varchar=? "
238246 + "and col_jsonb::text=?" ,
@@ -246,6 +254,7 @@ public void testParameterMetaData() throws SQLException {
246254 + "and col_int=? "
247255 + "and col_numeric=? "
248256 + "and col_timestamptz=? "
257+ + "and col_interval=? "
249258 + "and col_date=? "
250259 + "and col_varchar=? "
251260 + "and col_jsonb::text=?"
@@ -254,16 +263,16 @@ public void testParameterMetaData() throws SQLException {
254263 try (PreparedStatement statement = connection .prepareStatement (sql )) {
255264 ParameterMetaData metadata = statement .getParameterMetaData ();
256265 if (sql .startsWith ("update all_types set col_bool=?," )) {
257- assertEquals (sql , 10 , metadata .getParameterCount ());
258- } else {
259266 assertEquals (sql , 11 , metadata .getParameterCount ());
267+ } else {
268+ assertEquals (sql , 12 , metadata .getParameterCount ());
260269 }
261270 for (int index = 1 ; index <= metadata .getParameterCount (); index ++) {
262271 assertEquals (ParameterMetaData .parameterModeIn , metadata .getParameterMode (index ));
263272 assertEquals (ParameterMetaData .parameterNullableUnknown , metadata .isNullable (index ));
264273 }
265274 int index = 0 ;
266- if (metadata .getParameterCount () == 11 ) {
275+ if (metadata .getParameterCount () == 12 ) {
267276 assertEquals (sql , Types .BIGINT , metadata .getParameterType (++index ));
268277 }
269278 assertEquals (sql , Types .BIT , metadata .getParameterType (++index ));
@@ -273,6 +282,7 @@ public void testParameterMetaData() throws SQLException {
273282 assertEquals (sql , Types .BIGINT , metadata .getParameterType (++index ));
274283 assertEquals (sql , Types .NUMERIC , metadata .getParameterType (++index ));
275284 assertEquals (sql , Types .TIMESTAMP , metadata .getParameterType (++index ));
285+ assertEquals (sql , Types .VARCHAR , metadata .getParameterType (++index ));
276286 assertEquals (sql , Types .DATE , metadata .getParameterType (++index ));
277287 assertEquals (sql , Types .VARCHAR , metadata .getParameterType (++index ));
278288 // jsonb does not support the '=' operator, which means that when a jsonb parameter is
@@ -514,8 +524,8 @@ public void testInsertWithParameters() throws SQLException {
514524 connection .prepareStatement (
515525 "insert into all_types "
516526 + "(col_bigint, col_bool, col_bytea, col_float4, col_float8, col_int, col_numeric, "
517- + "col_timestamptz, col_date, col_varchar) "
518- + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" )) {
527+ + "col_timestamptz, col_interval, col_date, col_varchar) "
528+ + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" )) {
519529 // This forces the PG JDBC driver to use binary transfer mode for the results, and will
520530 // also cause it to send a DescribeStatement message.
521531 statement .unwrap (PgStatement .class ).setPrepareThreshold (-1 );
@@ -530,6 +540,7 @@ public void testInsertWithParameters() throws SQLException {
530540 statement .setBigDecimal (++index , new BigDecimal ("6.626" ));
531541 statement .setTimestamp (
532542 ++index , Timestamp .parseTimestamp ("2022-02-11T13:45:00.123456+01:00" ).toSqlTimestamp ());
543+ statement .setString (++index , "P1Y" );
533544 statement .setDate (++index , Date .valueOf ("2022-04-29" ));
534545 statement .setString (++index , "string_test" );
535546
@@ -552,6 +563,7 @@ public void testInsertWithParameters() throws SQLException {
552563 assertEquals (
553564 Timestamp .parseTimestamp ("2022-02-11T13:45:00.123456+01:00" ).toSqlTimestamp (),
554565 resultSet .getTimestamp (++index ));
566+ assertEquals ("P1Y" , resultSet .getString (++index ));
555567 assertEquals (Date .valueOf ("2022-04-29" ), resultSet .getDate (++index ));
556568 assertEquals ("string_test" , resultSet .getString (++index ));
557569
@@ -617,6 +629,7 @@ public void testUpdateWithParameters() throws SQLException {
617629 assertEquals (
618630 Timestamp .parseTimestamp ("2022-02-11T14:04:59.123457+01:00" ).toSqlTimestamp (),
619631 resultSet .getTimestamp (++index ));
632+ assertEquals ("P1Y2M3DT4H5M6" , resultSet .getString (++index ));
620633 assertEquals (Date .valueOf ("2000-02-29" ), resultSet .getDate (++index ));
621634 assertEquals ("updated" , resultSet .getString (++index ));
622635
0 commit comments