Skip to content

Commit 7425074

Browse files
committed
Added INVALID_DATE_AND_TIME_AS_MIN_VALUE EventDeserializer compatibility mode
1 parent fc5c2f0 commit 7425074

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/EventDeserializer.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ private void ensureCompatibility(EventDataDeserializer eventDataDeserializer) {
173173
}
174174
deserializer.setInvalidDateAndTimeRepresentation(-1L);
175175
}
176+
if (compatibilitySet.contains(CompatibilityMode.INVALID_DATE_AND_TIME_AS_MIN_VALUE)) {
177+
if (!deserializeDateAndTimeAsLong) {
178+
throw new IllegalArgumentException("INVALID_DATE_AND_TIME_AS_MIN_VALUE requires " +
179+
"DATE_AND_TIME_AS_LONG or DATE_AND_TIME_AS_LONG_MICRO");
180+
}
181+
deserializer.setInvalidDateAndTimeRepresentation(Long.MIN_VALUE);
182+
}
176183
deserializer.setDeserializeCharAndBinaryAsByteArray(
177184
compatibilitySet.contains(CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY)
178185
);
@@ -260,10 +267,13 @@ public enum CompatibilityMode {
260267
/**
261268
* Return -1 instead of null if year/month/day is 0.
262269
* Affects DATETIME/DATETIME_V2/DATE/TIME/TIME_V2.
263-
*
264-
* <p>This option is going to be enabled by default starting from mysql-binlog-connector-java@1.0.0.
265270
*/
266271
INVALID_DATE_AND_TIME_AS_NEGATIVE_ONE,
272+
/**
273+
* Return Long.MIN_VALUE instead of null if year/month/day is 0.
274+
* Affects DATETIME/DATETIME_V2/DATE/TIME/TIME_V2.
275+
*/
276+
INVALID_DATE_AND_TIME_AS_MIN_VALUE,
267277
/**
268278
* Return CHAR/VARCHAR/BINARY/VARBINARY values as byte[]|s (instead of String|s).
269279
*

0 commit comments

Comments
 (0)