1
0
mirror of synced 2025-12-25 02:09:19 -05:00

🐛 Rodi/port zero date time behavior fix (#33210)

Co-authored-by: Robert Tomczak <36033856+robertomczak@users.noreply.github.com>
Co-authored-by: robertomczak <robertomczak@users.noreply.github.com>
This commit is contained in:
Rodi Reich Zilberman
2023-12-11 11:09:14 -08:00
committed by GitHub
parent 5a4d64af8b
commit f5ae28fc0c
4 changed files with 152 additions and 140 deletions

View File

@@ -9,7 +9,7 @@ data:
connectorSubtype: database
connectorType: source
definitionId: 435bb9a5-7887-4809-aa58-28c27df0d7ad
dockerImageTag: 3.2.2
dockerImageTag: 3.2.3
dockerRepository: airbyte/source-mysql
documentationUrl: https://docs.airbyte.com/integrations/sources/mysql
githubIssueLabel: source-mysql

View File

@@ -318,7 +318,9 @@ public class MySqlSource extends AbstractJdbcSource<MysqlType> implements Source
// When using this approach MySql creates a temporary table which may have some effect on db
// performance.
jdbcUrl.append("?useCursorFetch=true");
jdbcUrl.append("&zeroDateTimeBehavior=convertToNull");
// What should happen when the driver encounters DATETIME values that are composed entirely of zeros
// https://dev.mysql.com/doc/connector-j/8.1/en/connector-j-connp-props-datetime-types-processing.html#cj-conn-prop_zeroDateTimeBehavior
jdbcUrl.append("&zeroDateTimeBehavior=CONVERT_TO_NULL");
// ensure the return tinyint(1) is boolean
jdbcUrl.append("&tinyInt1isBit=true");
// ensure the return year value is a Date; see the rationale

View File

@@ -255,6 +255,14 @@ public abstract class AbstractMySqlSourceDatatypeTest extends AbstractSourceData
.addExpectedValues((String) null)
.build());
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("date")
.airbyteType(JsonSchemaType.STRING_DATE)
.addInsertValues("0000-00-00")
.addExpectedValues((String) null)
.build());
for (final String fullSourceType : Set.of("datetime", "datetime not null default now()")) {
addDataTypeTestData(
TestDataHolder.builder()