comparison src/main/java/org/monetdb/jdbc/MonetParameterMetaData.java @ 887:674f9ed21308

Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types. Also extended test Test_Interval_Types() to test all 13 interval types, both as result column and as parameter.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 04 Apr 2024 12:56:33 +0200 (13 months ago)
parents e1f00e0e3598
children 549225b7be85
comparison
equal deleted inserted replaced
886:4f50019b2cf8 887:674f9ed21308
291 checkParameterIndexValidity(param); 291 checkParameterIndexValidity(param);
292 try { 292 try {
293 final String monettype = monetdbTypes[param]; 293 final String monettype = monetdbTypes[param];
294 if (monettype != null && monettype.endsWith("_interval")) { 294 if (monettype != null && monettype.endsWith("_interval")) {
295 /* convert the interval type names to valid SQL data type names */ 295 /* convert the interval type names to valid SQL data type names */
296 if ("day_interval".equals(monettype)) 296 switch (precisions[param]) {
297 return "interval day"; 297 case 1: return "interval year";
298 if ("month_interval".equals(monettype)) 298 case 2: return "interval year to month";
299 return "interval month"; 299 case 3: return "interval month";
300 if ("sec_interval".equals(monettype)) 300 case 4: return "interval day";
301 return "interval second"; 301 case 5: return "interval day to hour";
302 case 6: return "interval day to minute";
303 case 7: return "interval day to second";
304 case 8: return "interval hour";
305 case 9: return "interval hour to minute";
306 case 10: return "interval hour to second";
307 case 11: return "interval minute";
308 case 12: return "interval minute to second";
309 case 13: return "interval second";
310 default:
311 { // fall back to the 3 available monettype names
312 if ("day_interval".equals(monettype))
313 return "interval day";
314 if ("month_interval".equals(monettype))
315 return "interval month";
316 if ("sec_interval".equals(monettype))
317 return "interval second";
318 }
319 }
302 } 320 }
303 return monettype; 321 return monettype;
304 } catch (IndexOutOfBoundsException e) { 322 } catch (IndexOutOfBoundsException e) {
305 throw newSQLInvalidParameterIndexException(param); 323 throw newSQLInvalidParameterIndexException(param);
306 } 324 }