@@ -96,6 +96,8 @@ public void insertTestData() {
96
96
.to (new BigDecimal ("3.14" ))
97
97
.set ("col_timestamptz" )
98
98
.to (Timestamp .parseTimestamp ("2022-01-27T17:51:30+01:00" ))
99
+ .set ("col_interval" )
100
+ .to ("P1Y2M3DT4H5M6" )
99
101
.set ("col_date" )
100
102
.to (com .google .cloud .Date .parseDate ("2022-04-29" ))
101
103
.set ("col_varchar" )
@@ -153,7 +155,7 @@ public void testParameterMetaData() throws SQLException {
153
155
for (String sql :
154
156
new String [] {
155
157
"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 "
157
159
+ "from all_types "
158
160
+ "where col_bigint=? "
159
161
+ "and col_bool=? "
@@ -163,18 +165,19 @@ public void testParameterMetaData() throws SQLException {
163
165
+ "and col_int=? "
164
166
+ "and col_numeric=? "
165
167
+ "and col_timestamptz=? "
168
+ + "and col_interval=? "
166
169
+ "and col_date=? "
167
170
+ "and col_varchar=? "
168
171
+ "and col_jsonb::text=?" ,
169
172
"insert into all_types "
170
173
+ "(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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ,
173
176
"insert into all_types "
174
177
+ "(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) "
176
179
+ "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 "
178
181
+ "from all_types "
179
182
+ "where col_bigint=? "
180
183
+ "and col_bool=? "
@@ -184,13 +187,14 @@ public void testParameterMetaData() throws SQLException {
184
187
+ "and col_int=? "
185
188
+ "and col_numeric=? "
186
189
+ "and col_timestamptz=? "
190
+ + "and col_interval=? "
187
191
+ "and col_date=? "
188
192
+ "and col_varchar=? "
189
193
+ "and col_jsonb::text=?" ,
190
- "insert into all_types " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
194
+ "insert into all_types " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ,
191
195
"insert into all_types "
192
196
+ "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 "
194
198
+ "from all_types "
195
199
+ "where col_bigint=? "
196
200
+ "and col_bool=? "
@@ -200,6 +204,7 @@ public void testParameterMetaData() throws SQLException {
200
204
+ "and col_int=? "
201
205
+ "and col_numeric=? "
202
206
+ "and col_timestamptz=? "
207
+ + "and col_interval=? "
203
208
+ "and col_date=? "
204
209
+ "and col_varchar=? "
205
210
+ "and col_jsonb::text=?" ,
@@ -211,6 +216,7 @@ public void testParameterMetaData() throws SQLException {
211
216
+ "col_int=?, "
212
217
+ "col_numeric=?, "
213
218
+ "col_timestamptz=?, "
219
+ + "col_interval=?, "
214
220
+ "col_date=?, "
215
221
+ "col_varchar=?, "
216
222
+ "col_jsonb=?" ,
@@ -222,6 +228,7 @@ public void testParameterMetaData() throws SQLException {
222
228
+ "col_int=null, "
223
229
+ "col_numeric=null, "
224
230
+ "col_timestamptz=null, "
231
+ + "col_interval=null, "
225
232
+ "col_date=null, "
226
233
+ "col_varchar=null, "
227
234
+ "col_jsonb=null "
@@ -233,6 +240,7 @@ public void testParameterMetaData() throws SQLException {
233
240
+ "and col_int=? "
234
241
+ "and col_numeric=? "
235
242
+ "and col_timestamptz=? "
243
+ + "and col_interval=? "
236
244
+ "and col_date=? "
237
245
+ "and col_varchar=? "
238
246
+ "and col_jsonb::text=?" ,
@@ -246,6 +254,7 @@ public void testParameterMetaData() throws SQLException {
246
254
+ "and col_int=? "
247
255
+ "and col_numeric=? "
248
256
+ "and col_timestamptz=? "
257
+ + "and col_interval=? "
249
258
+ "and col_date=? "
250
259
+ "and col_varchar=? "
251
260
+ "and col_jsonb::text=?"
@@ -254,16 +263,16 @@ public void testParameterMetaData() throws SQLException {
254
263
try (PreparedStatement statement = connection .prepareStatement (sql )) {
255
264
ParameterMetaData metadata = statement .getParameterMetaData ();
256
265
if (sql .startsWith ("update all_types set col_bool=?," )) {
257
- assertEquals (sql , 10 , metadata .getParameterCount ());
258
- } else {
259
266
assertEquals (sql , 11 , metadata .getParameterCount ());
267
+ } else {
268
+ assertEquals (sql , 12 , metadata .getParameterCount ());
260
269
}
261
270
for (int index = 1 ; index <= metadata .getParameterCount (); index ++) {
262
271
assertEquals (ParameterMetaData .parameterModeIn , metadata .getParameterMode (index ));
263
272
assertEquals (ParameterMetaData .parameterNullableUnknown , metadata .isNullable (index ));
264
273
}
265
274
int index = 0 ;
266
- if (metadata .getParameterCount () == 11 ) {
275
+ if (metadata .getParameterCount () == 12 ) {
267
276
assertEquals (sql , Types .BIGINT , metadata .getParameterType (++index ));
268
277
}
269
278
assertEquals (sql , Types .BIT , metadata .getParameterType (++index ));
@@ -273,6 +282,7 @@ public void testParameterMetaData() throws SQLException {
273
282
assertEquals (sql , Types .BIGINT , metadata .getParameterType (++index ));
274
283
assertEquals (sql , Types .NUMERIC , metadata .getParameterType (++index ));
275
284
assertEquals (sql , Types .TIMESTAMP , metadata .getParameterType (++index ));
285
+ assertEquals (sql , Types .VARCHAR , metadata .getParameterType (++index ));
276
286
assertEquals (sql , Types .DATE , metadata .getParameterType (++index ));
277
287
assertEquals (sql , Types .VARCHAR , metadata .getParameterType (++index ));
278
288
// jsonb does not support the '=' operator, which means that when a jsonb parameter is
@@ -514,8 +524,8 @@ public void testInsertWithParameters() throws SQLException {
514
524
connection .prepareStatement (
515
525
"insert into all_types "
516
526
+ "(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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" )) {
519
529
// This forces the PG JDBC driver to use binary transfer mode for the results, and will
520
530
// also cause it to send a DescribeStatement message.
521
531
statement .unwrap (PgStatement .class ).setPrepareThreshold (-1 );
@@ -530,6 +540,7 @@ public void testInsertWithParameters() throws SQLException {
530
540
statement .setBigDecimal (++index , new BigDecimal ("6.626" ));
531
541
statement .setTimestamp (
532
542
++index , Timestamp .parseTimestamp ("2022-02-11T13:45:00.123456+01:00" ).toSqlTimestamp ());
543
+ statement .setString (++index , "P1Y" );
533
544
statement .setDate (++index , Date .valueOf ("2022-04-29" ));
534
545
statement .setString (++index , "string_test" );
535
546
@@ -552,6 +563,7 @@ public void testInsertWithParameters() throws SQLException {
552
563
assertEquals (
553
564
Timestamp .parseTimestamp ("2022-02-11T13:45:00.123456+01:00" ).toSqlTimestamp (),
554
565
resultSet .getTimestamp (++index ));
566
+ assertEquals ("P1Y" , resultSet .getString (++index ));
555
567
assertEquals (Date .valueOf ("2022-04-29" ), resultSet .getDate (++index ));
556
568
assertEquals ("string_test" , resultSet .getString (++index ));
557
569
@@ -617,6 +629,7 @@ public void testUpdateWithParameters() throws SQLException {
617
629
assertEquals (
618
630
Timestamp .parseTimestamp ("2022-02-11T14:04:59.123457+01:00" ).toSqlTimestamp (),
619
631
resultSet .getTimestamp (++index ));
632
+ assertEquals ("P1Y2M3DT4H5M6" , resultSet .getString (++index ));
620
633
assertEquals (Date .valueOf ("2000-02-29" ), resultSet .getDate (++index ));
621
634
assertEquals ("updated" , resultSet .getString (++index ));
622
635
0 commit comments