From 6e940df1edd83b175cecfc5be44a225fc03ce66d Mon Sep 17 00:00:00 2001 From: TobiasHafner Date: Sun, 11 Aug 2024 13:50:01 +0200 Subject: [PATCH] Fix setDate null bug --- src/main/java/org/polypheny/jdbc/types/TypedValue.java | 3 +++ src/main/java/org/polypheny/jdbc/utils/TypedValueUtils.java | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/polypheny/jdbc/types/TypedValue.java b/src/main/java/org/polypheny/jdbc/types/TypedValue.java index 0ae0be4..6a9736f 100644 --- a/src/main/java/org/polypheny/jdbc/types/TypedValue.java +++ b/src/main/java/org/polypheny/jdbc/types/TypedValue.java @@ -229,6 +229,9 @@ public static TypedValue fromDate( Date dateValue ) { public static TypedValue fromDate( Date dateValue, Calendar calendar ) { + if (dateValue == null) { + return fromNull(); + } return fromDate( TypedValueUtils.getDateInCalendar( dateValue, calendar ) ); } diff --git a/src/main/java/org/polypheny/jdbc/utils/TypedValueUtils.java b/src/main/java/org/polypheny/jdbc/utils/TypedValueUtils.java index 256679f..e127d65 100644 --- a/src/main/java/org/polypheny/jdbc/utils/TypedValueUtils.java +++ b/src/main/java/org/polypheny/jdbc/utils/TypedValueUtils.java @@ -114,7 +114,7 @@ public static Date getDateFromTimestamp( Timestamp timestamp ) { public static Date getDateInCalendar( Date date, Calendar calendar ) { - return new Date( getTimeLongInCalendar( date.getTime(), calendar ) ); + return new Date( getTimeLongInCalendar(date.getTime() , calendar ) ); } @@ -373,19 +373,15 @@ public static TypedValue buildTypedValueFromObject( Object value, int targetSqlT return buildTypedValueFromCalendar( (Calendar) value, targetSqlType ); } if ( value instanceof java.util.Date ) { - // requires conversion return buildTypedValueFromDate( (java.util.Date) value, targetSqlType ); } if ( value instanceof LocalDate ) { - // requires conversion return buildTypedValueFromLocalDate( (LocalDate) value, targetSqlType ); } if ( value instanceof LocalTime ) { - // requires conversion return buildTypedValueFromLocalTime( (LocalTime) value, targetSqlType ); } if ( value instanceof LocalDateTime ) { - //requires conversion return buildTypedValueFromLocalDateTime( (LocalDateTime) value, targetSqlType ); } if ( value instanceof OffsetTime ) {