-
Notifications
You must be signed in to change notification settings - Fork 5
Fix: handle tinyint(1) BOOLEAN inference with modifiers like NOT NULL
#72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,3 +256,30 @@ func TestCanDetectDecimalPrecision(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| //Adding an additional unit test for the tinyint(1) as bool handling since the orginals were not wide enough | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can remove this comment and the next line |
||
|
|
||
| func TestGetFivetranDataType_TinyintBooleanHandling(t *testing.T) { | ||
| tests := []struct { | ||
| mysqlType string | ||
| treatTinyIntAsBoolean bool | ||
| expected fivetransdk.DataType | ||
| }{ | ||
| {"tinyint(1)", true, fivetransdk.DataType_BOOLEAN}, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| {"tinyint(1) NOT NULL", true, fivetransdk.DataType_BOOLEAN}, | ||
| {"tinyint(1) unsigned", true, fivetransdk.DataType_BOOLEAN}, | ||
| {"tinyint(2)", true, fivetransdk.DataType_INT}, | ||
| {"tinyint", true, fivetransdk.DataType_INT}, | ||
| {"TINYINT(1)", true, fivetransdk.DataType_BOOLEAN}, | ||
| {"tinyint(1)", false, fivetransdk.DataType_INT}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(fmt.Sprintf("%s_bool_%t", tt.mysqlType, tt.treatTinyIntAsBoolean), func(t *testing.T) { | ||
| got, _ := getFivetranDataType(tt.mysqlType, tt.treatTinyIntAsBoolean) | ||
| if got != tt.expected { | ||
| t.Errorf("For input '%s', expected %s but got %s", tt.mysqlType, tt.expected, got) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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?