From 4398e5577a13e625903f3f3a3f338c49c78798e7 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Sun, 2 Feb 2025 14:22:17 -0800 Subject: [PATCH 1/2] Bug fix for encoding extended types in keys --- go/libraries/doltcore/schema/schema_impl.go | 55 +++++++++++---------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/go/libraries/doltcore/schema/schema_impl.go b/go/libraries/doltcore/schema/schema_impl.go index bd24fe037b2..565a5bea880 100644 --- a/go/libraries/doltcore/schema/schema_impl.go +++ b/go/libraries/doltcore/schema/schema_impl.go @@ -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 - } - - 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 { + _, contentHashedField := contentHashedFields[tag]; + extendedType, isExtendedType := sqlType.(gmstypes.ExtendedType); + + if isExtendedType { t = val.Type{ Enc: val.Encoding(EncodingFromSqlType(sqlType)), Nullable: columnMissingNotNullConstraint(col), } + } else { + 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) { @@ -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 }) From 9a2e242a9d1df1a0f85c6fd6a97aa3423d692b32 Mon Sep 17 00:00:00 2001 From: zachmu Date: Wed, 5 Feb 2025 02:08:06 +0000 Subject: [PATCH 2/2] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- go/libraries/doltcore/schema/schema_impl.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/go/libraries/doltcore/schema/schema_impl.go b/go/libraries/doltcore/schema/schema_impl.go index 565a5bea880..f23c46659fb 100644 --- a/go/libraries/doltcore/schema/schema_impl.go +++ b/go/libraries/doltcore/schema/schema_impl.go @@ -497,15 +497,15 @@ func (si *schemaImpl) getKeyColumnsDescriptor(convertAddressColumns bool) val.Tu queryType := sqlType.Type() var t val.Type - _, contentHashedField := contentHashedFields[tag]; - extendedType, isExtendedType := sqlType.(gmstypes.ExtendedType); - + _, contentHashedField := contentHashedFields[tag] + extendedType, isExtendedType := sqlType.(gmstypes.ExtendedType) + if isExtendedType { t = val.Type{ Enc: val.Encoding(EncodingFromSqlType(sqlType)), Nullable: columnMissingNotNullConstraint(col), } - } else { + } else { if convertAddressColumns && !contentHashedField && queryType == query.Type_BLOB { t = val.Type{ Enc: val.Encoding(EncodingFromQueryType(query.Type_VARBINARY)), @@ -528,7 +528,7 @@ func (si *schemaImpl) getKeyColumnsDescriptor(convertAddressColumns bool) val.Tu } } } - + tt = append(tt, t) stringType, isStringType := sqlType.(sql.StringType) if isStringType && (queryType == query.Type_CHAR || queryType == query.Type_VARCHAR || queryType == query.Type_TEXT) { @@ -539,7 +539,7 @@ func (si *schemaImpl) getKeyColumnsDescriptor(convertAddressColumns bool) val.Tu } handlers = append(handlers, extendedType) - + return })