fix concurrency bug in pgtype.defaultMap (#1650)

pull/1653/head
Lev Zakharov 2023-06-18 15:36:48 +03:00 committed by Jack Christensen
parent 9a5ead9048
commit 7c386112e3
2 changed files with 2 additions and 4 deletions

View File

@ -318,10 +318,6 @@ func (m *Map) TypeForValue(v any) (*Type, bool) {
return dt, true
}
if defaultMap.reflectTypeToType == nil {
defaultMap.buildReflectTypeToType()
}
dt, ok := defaultMap.reflectTypeToType[reflect.TypeOf(v)]
return dt, ok
}

View File

@ -218,4 +218,6 @@ func initDefaultMap() {
registerDefaultPgTypeVariants[Range[Timestamptz]](defaultMap, "tstzrange")
registerDefaultPgTypeVariants[Multirange[Range[Timestamptz]]](defaultMap, "tstzmultirange")
registerDefaultPgTypeVariants[UUID](defaultMap, "uuid")
defaultMap.buildReflectTypeToType()
}