Skip to content

Conversation

@WittgensteinBeetle
Copy link

Problem

The getFivetranDataType function originally only returned BOOLEAN if the MySQL type was exactly "tinyint(1)". This excluded common real-world variants like:

  • tinyint(1) NOT NULL
  • tinyint(1) unsigned
  • tinyint(1) zerofill
  • TINYINT(1) (case insensitivity)

These types should be safely treated as booleans when treatTinyIntAsBoolean is enabled — which matches MySQL connector behavior and expectations from most CDC systems.


Fix

The logic has been updated to:

  • Normalize mysqlType to lowercase
  • Split it by whitespace (using strings.Fields)
  • Only evaluate the base type (e.g., "tinyint(1)") for the boolean match

This avoids false negatives while ensuring that tinyint(2+) are not misclassified as booleans.


Test Coverage

Added unit tests for:

  • tinyint(1) -- Pass
  • tinyint(1) NOT NULL -- Pass
  • tinyint(1) unsigned -- Pass
  • tinyint(2) -- Fail
  • tinyint -- Fail
  • TINYINT(1) -- Pass

Added an additional unit test to include these parameters as the original did not include these edge cases

Copy link
Collaborator

@maxenglander maxenglander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good, will approve this once tests pass and my comments are addressed

}
}

//Adding an additional unit test for the tinyint(1) as bool handling since the orginals were not wide enough
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this comment and the next line

treatTinyIntAsBoolean bool
expected fivetransdk.DataType
}{
{"tinyint(1)", true, fivetransdk.DataType_BOOLEAN},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason these test cases can't fit as cases into the existing TestSchema_CanPickRightFivetranType test rather than defining a new test?


//empty schema condition
if len(parts) == 0 {
return fivetransdk.DataType_UNSPECIFIED, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, can we add a test case for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants