Skip to content

Commit

Permalink
Merge pull request dolthub#8817 from dolthub/zachmu/extended-encoding
Browse files Browse the repository at this point in the history
Bug fix for encoding extended types in keys
  • Loading branch information
zachmu authored Feb 5, 2025
2 parents cc43725 + 9a2e242 commit 9e36f51
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions go/libraries/doltcore/schema/schema_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,32 +497,38 @@ func (si *schemaImpl) getKeyColumnsDescriptor(convertAddressColumns bool) val.Tu
queryType := sqlType.Type()
var t val.Type

contentHashedField := false
if _, ok := contentHashedFields[tag]; ok {
contentHashedField = true
}
_, contentHashedField := contentHashedFields[tag]
extendedType, isExtendedType := sqlType.(gmstypes.ExtendedType)

if convertAddressColumns && !contentHashedField && queryType == query.Type_BLOB {
t = val.Type{
Enc: val.Encoding(EncodingFromQueryType(query.Type_VARBINARY)),
Nullable: columnMissingNotNullConstraint(col),
}
} else if convertAddressColumns && !contentHashedField && queryType == query.Type_TEXT {
t = val.Type{
Enc: val.Encoding(EncodingFromQueryType(query.Type_VARCHAR)),
Nullable: columnMissingNotNullConstraint(col),
}
} else if convertAddressColumns && !contentHashedField && queryType == query.Type_GEOMETRY {
if isExtendedType {
t = val.Type{
Enc: val.Encoding(serial.EncodingCell),
Enc: val.Encoding(EncodingFromSqlType(sqlType)),
Nullable: columnMissingNotNullConstraint(col),
}
} else {
t = val.Type{
Enc: val.Encoding(EncodingFromSqlType(sqlType)),
Nullable: columnMissingNotNullConstraint(col),
if convertAddressColumns && !contentHashedField && queryType == query.Type_BLOB {
t = val.Type{
Enc: val.Encoding(EncodingFromQueryType(query.Type_VARBINARY)),
Nullable: columnMissingNotNullConstraint(col),
}
} else if convertAddressColumns && !contentHashedField && queryType == query.Type_TEXT {
t = val.Type{
Enc: val.Encoding(EncodingFromQueryType(query.Type_VARCHAR)),
Nullable: columnMissingNotNullConstraint(col),
}
} else if convertAddressColumns && !contentHashedField && queryType == query.Type_GEOMETRY {
t = val.Type{
Enc: val.Encoding(serial.EncodingCell),
Nullable: columnMissingNotNullConstraint(col),
}
} else {
t = val.Type{
Enc: val.Encoding(EncodingFromSqlType(sqlType)),
Nullable: columnMissingNotNullConstraint(col),
}
}
}

tt = append(tt, t)
stringType, isStringType := sqlType.(sql.StringType)
if isStringType && (queryType == query.Type_CHAR || queryType == query.Type_VARCHAR || queryType == query.Type_TEXT) {
Expand All @@ -532,11 +538,8 @@ func (si *schemaImpl) getKeyColumnsDescriptor(convertAddressColumns bool) val.Tu
collations = append(collations, sql.Collation_Unspecified)
}

if extendedType, ok := sqlType.(gmstypes.ExtendedType); ok {
handlers = append(handlers, extendedType)
} else {
handlers = append(handlers, nil)
}
handlers = append(handlers, extendedType)

return
})

Expand Down

0 comments on commit 9e36f51

Please sign in to comment.