Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetResultSetMetaData.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 | 4f50019b2cf8 |
children | 549225b7be85 |
comparison
equal
deleted
inserted
replaced
886:4f50019b2cf8 | 887:674f9ed21308 |
---|---|
541 final String monettype = types[column - 1]; | 541 final String monettype = types[column - 1]; |
542 if (monettype != null && monettype.endsWith("_interval")) { | 542 if (monettype != null && monettype.endsWith("_interval")) { |
543 /* convert the interval type names to valid SQL data type names, | 543 /* convert the interval type names to valid SQL data type names, |
544 * such that generic applications can use them in create table statements | 544 * such that generic applications can use them in create table statements |
545 */ | 545 */ |
546 if ("day_interval".equals(monettype)) | 546 int prec = -1; |
547 return "interval day"; | 547 if (precisions != null) { |
548 if ("month_interval".equals(monettype)) | 548 prec = precisions[column - 1]; |
549 return "interval month"; | 549 } |
550 if ("sec_interval".equals(monettype)) | 550 switch (prec) { |
551 return "interval second"; | 551 case 1: return "interval year"; |
552 case 2: return "interval year to month"; | |
553 case 3: return "interval month"; | |
554 case 4: return "interval day"; | |
555 case 5: return "interval day to hour"; | |
556 case 6: return "interval day to minute"; | |
557 case 7: return "interval day to second"; | |
558 case 8: return "interval hour"; | |
559 case 9: return "interval hour to minute"; | |
560 case 10: return "interval hour to second"; | |
561 case 11: return "interval minute"; | |
562 case 12: return "interval minute to second"; | |
563 case 13: return "interval second"; | |
564 default: // when no precisions array was available | |
565 { // fall back to the 3 available monettype names | |
566 if ("day_interval".equals(monettype)) | |
567 return "interval day"; | |
568 if ("month_interval".equals(monettype)) | |
569 return "interval month"; | |
570 if ("sec_interval".equals(monettype)) | |
571 return "interval second"; | |
572 } | |
573 } | |
552 } | 574 } |
553 return monettype; | 575 return monettype; |
554 } catch (IndexOutOfBoundsException e) { | 576 } catch (IndexOutOfBoundsException e) { |
555 throw MonetResultSet.newSQLInvalidColumnIndexException(column); | 577 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
556 } | 578 } |