2
0

Rename CloneTypeValue to NewTypeValue

This commit is contained in:
Jack Christensen
2020-05-12 10:26:51 -05:00
parent bff2829b0f
commit 682201a4fc
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ func NewArrayType(typeName string, newElement func() ValueTranscoder) *ArrayType
return &ArrayType{typeName: typeName, newElement: newElement} return &ArrayType{typeName: typeName, newElement: newElement}
} }
func (at *ArrayType) CloneTypeValue() Value { func (at *ArrayType) NewTypeValue() Value {
return &ArrayType{ return &ArrayType{
elements: at.elements, elements: at.elements,
dimensions: at.dimensions, dimensions: at.dimensions,
+1 -1
View File
@@ -31,7 +31,7 @@ func NewEnumType(typeName string, members []string) EnumType {
return et return et
} }
func (et *enumType) CloneTypeValue() Value { func (et *enumType) NewTypeValue() Value {
return &enumType{ return &enumType{
value: et.value, value: et.value,
status: et.status, status: et.status,
+4 -4
View File
@@ -134,9 +134,9 @@ type Value interface {
// In general, instances of TypeValue should not be used to directly represent a value. It should only be used as an // In general, instances of TypeValue should not be used to directly represent a value. It should only be used as an
// encoder and decoder internal to ConnInfo. // encoder and decoder internal to ConnInfo.
type TypeValue interface { type TypeValue interface {
// CloneTypeValue duplicates a TypeValue including references to internal type information. e.g. the list of members // NewTypeValue creates a TypeValue including references to internal type information. e.g. the list of members
// in an EnumType. // in an EnumType.
CloneTypeValue() Value NewTypeValue() Value
// TypeName returns the PostgreSQL name of this type. // TypeName returns the PostgreSQL name of this type.
TypeName() string TypeName() string
@@ -359,7 +359,7 @@ func (ci *ConnInfo) InitializeDataTypes(nameOIDs map[string]uint32) {
func (ci *ConnInfo) RegisterDataType(t DataType) { func (ci *ConnInfo) RegisterDataType(t DataType) {
if tv, ok := t.Value.(TypeValue); ok { if tv, ok := t.Value.(TypeValue); ok {
t.Value = tv.CloneTypeValue() t.Value = tv.NewTypeValue()
} }
ci.oidToDataType[t.OID] = &t ci.oidToDataType[t.OID] = &t
@@ -469,7 +469,7 @@ func (ci *ConnInfo) DeepCopy() *ConnInfo {
for _, dt := range ci.oidToDataType { for _, dt := range ci.oidToDataType {
var value Value var value Value
if tv, ok := dt.Value.(TypeValue); ok { if tv, ok := dt.Value.(TypeValue); ok {
value = tv.CloneTypeValue() value = tv.NewTypeValue()
} else { } else {
value = reflect.New(reflect.ValueOf(dt.Value).Elem().Type()).Interface().(Value) value = reflect.New(reflect.ValueOf(dt.Value).Elem().Type()).Interface().(Value)
} }