|
16 | 16 | import java.util.Objects; |
17 | 17 | import java.util.concurrent.TimeUnit; |
18 | 18 |
|
| 19 | +import tech.ydb.jdbc.YdbConst; |
19 | 20 | import tech.ydb.jdbc.impl.YdbTypesImpl; |
20 | 21 | import tech.ydb.table.result.PrimitiveReader; |
21 | 22 | import tech.ydb.table.result.ValueReader; |
|
24 | 25 | import tech.ydb.table.values.Type; |
25 | 26 | import tech.ydb.table.values.Value; |
26 | 27 |
|
27 | | -import static tech.ydb.jdbc.YdbConst.UNABLE_TO_CAST; |
28 | | -import static tech.ydb.jdbc.YdbConst.UNABLE_TO_CONVERT; |
29 | 28 | import static tech.ydb.table.values.PrimitiveType.Bool; |
30 | 29 | import static tech.ydb.table.values.PrimitiveType.Bytes; |
31 | 30 | import static tech.ydb.table.values.PrimitiveType.Date; |
@@ -96,6 +95,25 @@ static Getters buildGetters(Type type) { |
96 | 95 | value -> value.getDecimal().toBigDecimal(), |
97 | 96 | castToReaderNotSupported(clazz) |
98 | 97 | ); |
| 98 | + case VOID: |
| 99 | + case NULL: |
| 100 | + return new Getters( |
| 101 | + value -> null, |
| 102 | + value -> false, |
| 103 | + value -> 0, |
| 104 | + value -> 0, |
| 105 | + value -> 0, |
| 106 | + value -> 0, |
| 107 | + value -> 0, |
| 108 | + value -> 0, |
| 109 | + value -> null, |
| 110 | + value -> null, |
| 111 | + value -> 0, |
| 112 | + value -> null, |
| 113 | + value -> null, |
| 114 | + value -> null, |
| 115 | + value -> null |
| 116 | + ); |
99 | 117 | default: |
100 | 118 | return new Getters( |
101 | 119 | value -> String.valueOf(value.getValue()), |
@@ -675,88 +693,88 @@ private static ValueToObject valueToObject(PrimitiveType id) { |
675 | 693 | } |
676 | 694 |
|
677 | 695 | private static SQLException cannotConvert(PrimitiveType type, Class<?> javaType, Object value) { |
678 | | - return new SQLException(String.format(UNABLE_TO_CONVERT, type, value, javaType)); |
| 696 | + return new SQLException(String.format(YdbConst.UNABLE_TO_CONVERT, type, value, javaType)); |
679 | 697 | } |
680 | 698 |
|
681 | 699 | private static SQLException dataTypeNotSupported(PrimitiveType type, Class<?> javaType) { |
682 | | - return new SQLException(String.format(UNABLE_TO_CAST, type, javaType)); |
| 700 | + return new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, javaType)); |
683 | 701 | } |
684 | 702 |
|
685 | 703 | private static ValueToBoolean castToBooleanNotSupported(String type) { |
686 | 704 | return value -> { |
687 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, boolean.class)); |
| 705 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, boolean.class)); |
688 | 706 | }; |
689 | 707 | } |
690 | 708 |
|
691 | 709 | private static ValueToByte castToByteNotSupported(String type) { |
692 | 710 | return value -> { |
693 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, byte.class)); |
| 711 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, byte.class)); |
694 | 712 | }; |
695 | 713 | } |
696 | 714 |
|
697 | 715 | private static ValueToShort castToShortNotSupported(String type) { |
698 | 716 | return value -> { |
699 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, short.class)); |
| 717 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, short.class)); |
700 | 718 | }; |
701 | 719 | } |
702 | 720 |
|
703 | 721 | private static ValueToInt castToIntNotSupported(String type) { |
704 | 722 | return value -> { |
705 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, int.class)); |
| 723 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, int.class)); |
706 | 724 | }; |
707 | 725 | } |
708 | 726 |
|
709 | 727 | private static ValueToLong castToLongNotSupported(String type) { |
710 | 728 | return value -> { |
711 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, long.class)); |
| 729 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, long.class)); |
712 | 730 | }; |
713 | 731 | } |
714 | 732 |
|
715 | 733 | private static ValueToFloat castToFloatNotSupported(String type) { |
716 | 734 | return value -> { |
717 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, float.class)); |
| 735 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, float.class)); |
718 | 736 | }; |
719 | 737 | } |
720 | 738 |
|
721 | 739 | private static ValueToDouble castToDoubleNotSupported(String type) { |
722 | 740 | return value -> { |
723 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, double.class)); |
| 741 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, double.class)); |
724 | 742 | }; |
725 | 743 | } |
726 | 744 |
|
727 | 745 | private static ValueToBytes castToBytesNotSupported(String type) { |
728 | 746 | return value -> { |
729 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, byte[].class)); |
| 747 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, byte[].class)); |
730 | 748 | }; |
731 | 749 | } |
732 | 750 |
|
733 | 751 | private static ValueToDateMillis castToDateMillisNotSupported(String type) { |
734 | 752 | return value -> { |
735 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, long.class)); |
| 753 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, long.class)); |
736 | 754 | }; |
737 | 755 | } |
738 | 756 |
|
739 | 757 | private static ValueToNString castToNStringNotSupported(String type) { |
740 | 758 | return value -> { |
741 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, String.class)); |
| 759 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, String.class)); |
742 | 760 | }; |
743 | 761 | } |
744 | 762 |
|
745 | 763 | private static ValueToURL castToUrlNotSupported(String type) { |
746 | 764 | return value -> { |
747 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, URL.class)); |
| 765 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, URL.class)); |
748 | 766 | }; |
749 | 767 | } |
750 | 768 |
|
751 | 769 | private static ValueToBigDecimal castToBigDecimalNotSupported(String type) { |
752 | 770 | return value -> { |
753 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, BigDecimal.class)); |
| 771 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, BigDecimal.class)); |
754 | 772 | }; |
755 | 773 | } |
756 | 774 |
|
757 | 775 | private static ValueToReader castToReaderNotSupported(String type) { |
758 | 776 | return value -> { |
759 | | - throw new SQLException(String.format(UNABLE_TO_CAST, type, Reader.class)); |
| 777 | + throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST, type, Reader.class)); |
760 | 778 | }; |
761 | 779 | } |
762 | 780 |
|
|
0 commit comments