comparison src/main/java/org/monetdb/jdbc/MonetParameterMetaData.java @ 888:549225b7be85

Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 04 Apr 2024 15:14:53 +0200 (13 months ago)
parents 674f9ed21308
children d416e9b6b3d0
comparison
equal deleted inserted replaced
887:674f9ed21308 888:549225b7be85
196 return 15; 196 return 15;
197 case Types.DECIMAL: 197 case Types.DECIMAL:
198 case Types.NUMERIC: 198 case Types.NUMERIC:
199 // these data types have a variable precision (max precision is 38) 199 // these data types have a variable precision (max precision is 38)
200 try { 200 try {
201 // Special handling for: day_interval and sec_interval as they are
202 // mapped to Types.NUMERIC and Types.DECIMAL types (see MonetDriver typeMap)
203 final String monettype = monetdbTypes[param];
204 if (monettype != null && monettype.endsWith("_interval")) {
205 /* for interval types, precisions[] contains the interval subtype code */
206 switch (precisions[param]) {
207 case 1: return 4; // interval year
208 case 2: return 6; // interval year to month
209 case 3: return 6; // interval month
210 case 4: return 9; // interval day
211 case 5: return 11; // interval day to hour
212 case 6: return 13; // interval day to minute
213 case 7: return 15; // interval day to second
214 case 8: return 11; // interval hour
215 case 9: return 13; // interval hour to minute
216 case 10: return 15; // interval hour to second
217 case 11: return 13; // interval minute
218 case 12: return 15; // interval minute to second
219 case 13: return 15; // interval second
220 default:
221 { // fall back to the 3 available monettype names
222 if ("sec_interval".equals(monettype))
223 return 15;
224 if ("day_interval".equals(monettype))
225 return 9;
226 if ("month_interval".equals(monettype))
227 return 6;
228 }
229 }
230 }
201 return precisions[param]; 231 return precisions[param];
202 } catch (IndexOutOfBoundsException e) { 232 } catch (IndexOutOfBoundsException e) {
203 throw newSQLInvalidParameterIndexException(param); 233 throw newSQLInvalidParameterIndexException(param);
204 } 234 }
205 case Types.CHAR: 235 case Types.CHAR:
291 checkParameterIndexValidity(param); 321 checkParameterIndexValidity(param);
292 try { 322 try {
293 final String monettype = monetdbTypes[param]; 323 final String monettype = monetdbTypes[param];
294 if (monettype != null && monettype.endsWith("_interval")) { 324 if (monettype != null && monettype.endsWith("_interval")) {
295 /* convert the interval type names to valid SQL data type names */ 325 /* convert the interval type names to valid SQL data type names */
326 /* for interval types, precisions[] contains the interval subtype code */
296 switch (precisions[param]) { 327 switch (precisions[param]) {
297 case 1: return "interval year"; 328 case 1: return "interval year";
298 case 2: return "interval year to month"; 329 case 2: return "interval year to month";
299 case 3: return "interval month"; 330 case 3: return "interval month";
300 case 4: return "interval day"; 331 case 4: return "interval day";