-
Notifications
You must be signed in to change notification settings - Fork 198
fix: cast enums to integers during qrep for mysql without binlog metadata … #4057
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3447599
cast enums to integers during qrep for mysql without binlog metadata …
dtunikov d2e3382
fix lint errs and address copilot comments
dtunikov bbd884b
use "enum AS UNSIGNED" cast instead of "+0"
dtunikov 4e5c07c
add internal version control for qrep migration
dtunikov ba10c5d
minor renaming
dtunikov 3186e7f
introduce QValueKindUint16Enum for integer enums (like mysql5 where e…
dtunikov 00ca9d7
rm old enum branch for unsigned mysql values
dtunikov 647af68
Merge branch 'main' of github.com:PeerDB-io/peerdb into fix/3950-enum…
dtunikov 257cc9a
minor code simplification
dtunikov eac0f39
Merge branch 'main' of github.com:PeerDB-io/peerdb into fix/3950-enum…
dtunikov 364a75a
- compare real enum values after cdc
dtunikov 6aedfbf
fix column order in tests
dtunikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package connmysql | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/PeerDB-io/peerdb/flow/generated/protos" | ||
| "github.com/PeerDB-io/peerdb/flow/shared/types" | ||
| ) | ||
|
|
||
| func TestBuildSelectedColumns(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| expectedSelectedColumns string | ||
| cols []*protos.FieldDescription | ||
| exclude []string | ||
| }{ | ||
| { | ||
| name: "no excluded columns, string enums", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "name", Type: string(types.QValueKindString)}, | ||
| {Name: "status", Type: string(types.QValueKindEnum)}, | ||
| }, | ||
| exclude: []string{}, | ||
| expectedSelectedColumns: "*", | ||
| }, | ||
| { | ||
| name: "one excluded column", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "name", Type: string(types.QValueKindString)}, | ||
| }, | ||
| exclude: []string{"name"}, | ||
| expectedSelectedColumns: "`id`", | ||
| }, | ||
| { | ||
| name: "uint16enum column is cast to unsigned", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "status", Type: string(types.QValueKindUint16Enum)}, | ||
| }, | ||
| exclude: []string{}, | ||
| expectedSelectedColumns: "`id`, CAST(`status` AS UNSIGNED) AS `status`", | ||
| }, | ||
| { | ||
| name: "string enum column is not cast", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "status", Type: string(types.QValueKindEnum)}, | ||
| }, | ||
| exclude: []string{}, | ||
| expectedSelectedColumns: "*", | ||
| }, | ||
| { | ||
| name: "uint16enum with exclude", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "status", Type: string(types.QValueKindUint16Enum)}, | ||
| {Name: "created_at", Type: string(types.QValueKindTimestamp)}, | ||
| }, | ||
| exclude: []string{"created_at"}, | ||
| expectedSelectedColumns: "`id`, CAST(`status` AS UNSIGNED) AS `status`", | ||
| }, | ||
| { | ||
| name: "string enum with exclude", | ||
| cols: []*protos.FieldDescription{ | ||
| {Name: "id", Type: string(types.QValueKindInt32)}, | ||
| {Name: "status", Type: string(types.QValueKindEnum)}, | ||
| {Name: "created_at", Type: string(types.QValueKindTimestamp)}, | ||
| }, | ||
| exclude: []string{"created_at"}, | ||
| expectedSelectedColumns: "`id`, `status`", | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| selectedColumns := buildSelectedColumns(tc.cols, tc.exclude) | ||
| if selectedColumns != tc.expectedSelectedColumns { | ||
| t.Errorf("expected selected columns to be %s, but got %s", tc.expectedSelectedColumns, selectedColumns) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
This is not really necessary (we could always query columns explicitly).
But I decided that this way it will be consistent with the current behaviour (no transformations -> select *)