Fixes for GMS bump

This commit is contained in:
Daylon Wilkins
2022-08-29 14:48:57 -07:00
parent c69e407efa
commit a88f9ef518
3 changed files with 14 additions and 4 deletions

View File

@@ -303,6 +303,12 @@ func WriteEWKBPolyData(p sql.Polygon, buf []byte) {
}
}
// The Type.SQL() call takes in a SQL context to determine the output character set for types that use a collation.
// As the SqlColToStr utility function is primarily used in places where no SQL context is available (such as commands
// on the CLI), we force the `utf8mb4` character set to be used, as it is the most likely to be supported by the
// destination. `utf8mb4` is the default character set for empty contexts, so we don't need to explicitly set it.
var sqlColToStrContext = sql.NewEmptyContext()
// SqlColToStr is a utility function for converting a sql column of type interface{} to a string
func SqlColToStr(sqlType sql.Type, col interface{}) (string, error) {
if col != nil {
@@ -314,7 +320,7 @@ func SqlColToStr(sqlType sql.Type, col interface{}) (string, error) {
return "false", nil
}
default:
res, err := sqlType.SQL(nil, col)
res, err := sqlType.SQL(sqlColToStrContext, nil, col)
if err != nil {
return "", err
}

View File

@@ -144,6 +144,12 @@ func (j *RowWriter) WriteRow(ctx context.Context, r row.Row) error {
}
func (j *RowWriter) WriteSqlRow(ctx context.Context, row sql.Row) error {
// The Type.SQL() call takes in a SQL context to determine the output character set for types that use a collation.
// The context given is not a SQL context, so we force the `utf8mb4` character set to be used, as it is the most
// likely to be supported by the destination. `utf8mb4` is the default character set for empty SQL contexts, so we
// don't need to explicitly set it.
sqlContext := sql.NewEmptyContext()
if j.rowsWritten == 0 {
err := iohelp.WriteAll(j.bWr, []byte(j.header))
if err != nil {
@@ -169,7 +175,7 @@ func (j *RowWriter) WriteSqlRow(ctx context.Context, row sql.Row) error {
typeinfo.TupleTypeIdentifier,
typeinfo.UuidTypeIdentifier,
typeinfo.VarBinaryTypeIdentifier:
sqlVal, err := col.TypeInfo.ToSqlType().SQL(nil, val)
sqlVal, err := col.TypeInfo.ToSqlType().SQL(sqlContext, nil, val)
if err != nil {
return true, err
}

View File

@@ -51,7 +51,6 @@ teardown() {
run dolt sql -q "SELECT * FROM german1 WHERE c = 'Bär'"
[ $status -eq 0 ]
[[ $output =~ 'Bar' ]] || false
skip "Daylon has a GMS PR to fix this"
[[ $output =~ 'Bär' ]] || false
[ ${#lines[@]} -eq 6 ]
@@ -88,7 +87,6 @@ teardown() {
run dolt sql -q "SELECT * FROM german1 WHERE c = 'Bär'"
[ $status -eq 0 ]
[[ ! $output =~ 'Bar' ]] || false
skip "Daylon has a GMS PR to fix this"
[[ $output =~ 'Bär' ]] || false
[ ${#lines[@]} -eq 5 ]
}