|
4 | 4 | "context" |
5 | 5 | "crypto/rand" |
6 | 6 | "database/sql" |
| 7 | + "database/sql/driver" |
7 | 8 | "fmt" |
8 | 9 | "math/big" |
9 | 10 | "strings" |
@@ -65,8 +66,10 @@ func TestAlwaysEncryptedE2E(t *testing.T) { |
65 | 66 | {"datetimeoffset(7)", "DATETIMEOFFSET", ColumnEncryptionRandomized, dt}, |
66 | 67 | {"datetime2(7)", "DATETIME2", ColumnEncryptionDeterministic, civil.DateTimeOf(dt)}, |
67 | 68 | {"nvarchar(max)", "NVARCHAR", ColumnEncryptionRandomized, NVarCharMax("nvarcharmaxval")}, |
68 | | - // TODO: The driver throws away type information about Valuer implementations and sends nil as nvarchar(1). Fix that. |
69 | | - // {"int", "INT", ColumnEncryptionDeterministic, sql.NullInt32{Valid: false}}, |
| 69 | + {"int", "INT", ColumnEncryptionDeterministic, sql.NullInt32{Valid: false}}, |
| 70 | + {"bigint", "BIGINT", ColumnEncryptionDeterministic, sql.NullInt64{Int64: 128, Valid: true}}, |
| 71 | + {"uniqueidentifier", "UNIQUEIDENTIFIER", ColumnEncryptionRandomized, UniqueIdentifier{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}}, |
| 72 | + {"uniqueidentifier", "UNIQUEIDENTIFIER", ColumnEncryptionRandomized, NullUniqueIdentifier{Valid: false}}, |
70 | 73 | } |
71 | 74 | for _, test := range providerTests { |
72 | 75 | // turn off key caching |
@@ -230,13 +233,19 @@ func comparisonValueFromObject(object interface{}) string { |
230 | 233 | case time.Time: |
231 | 234 | return civil.DateTimeOf(v).String() |
232 | 235 | //return v.Format(time.RFC3339) |
233 | | - case fmt.Stringer: |
234 | | - return v.String() |
235 | 236 | case bool: |
236 | 237 | if v == true { |
237 | 238 | return "1" |
238 | 239 | } |
239 | 240 | return "0" |
| 241 | + case driver.Valuer: |
| 242 | + val, _ := v.Value() |
| 243 | + if val == nil { |
| 244 | + return "<nil>" |
| 245 | + } |
| 246 | + return comparisonValueFromObject(val) |
| 247 | + case fmt.Stringer: |
| 248 | + return v.String() |
240 | 249 | default: |
241 | 250 | return fmt.Sprintf("%v", v) |
242 | 251 | } |
|
0 commit comments