-
Notifications
You must be signed in to change notification settings - Fork 116
go sqlgen: binlog testers should compare driver.Values #170
Conversation
We want to use Valuer to convert a filter value into driver.Value so we run equality check on well-known driver.Value types. This means we need to feed arbitrary filter value into Valuer, and its logic should respect the value type that is passed in.
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.
I'm happy with the amount of tests here 😊
return f.value.Int(), nil | ||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: | ||
return int64(f.value.Uint()), nil |
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, thanks for catching this
@@ -88,13 +88,13 @@ func (f Valuer) Value() (driver.Value, error) { | |||
// Coerce our value into a valid sql/driver.Value (see sql/driver.IsValue). | |||
// This not only converts base types into their sql counterparts (like int32 -> int64) but also | |||
// handles custom types (like `type customString string` -> string). | |||
switch f.Kind { | |||
switch f.value.Kind() { |
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.
😬 I'm scared
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.
(test plan?)
return false | ||
} | ||
|
||
// Special case: if both driver.Value are slices, compare their byte values. |
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
I will land on staging tomorrow. 🙏 |
db14bb6
to
074bd04
Compare
Pull Request Test Coverage Report for Build 1048
💛 - Coveralls |
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.
👍 staging test went well, good to go!
Currently binlog tester does not match int32 filter value against a int64 column, for example. It doesn't support custom type either. This fixes both.