mirror of https://github.com/jackc/pgx.git
fix concurrency bug in pgtype.defaultMap (#1650)
parent
9a5ead9048
commit
7c386112e3
|
@ -318,10 +318,6 @@ func (m *Map) TypeForValue(v any) (*Type, bool) {
|
||||||
return dt, true
|
return dt, true
|
||||||
}
|
}
|
||||||
|
|
||||||
if defaultMap.reflectTypeToType == nil {
|
|
||||||
defaultMap.buildReflectTypeToType()
|
|
||||||
}
|
|
||||||
|
|
||||||
dt, ok := defaultMap.reflectTypeToType[reflect.TypeOf(v)]
|
dt, ok := defaultMap.reflectTypeToType[reflect.TypeOf(v)]
|
||||||
return dt, ok
|
return dt, ok
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,6 @@ func initDefaultMap() {
|
||||||
registerDefaultPgTypeVariants[Range[Timestamptz]](defaultMap, "tstzrange")
|
registerDefaultPgTypeVariants[Range[Timestamptz]](defaultMap, "tstzrange")
|
||||||
registerDefaultPgTypeVariants[Multirange[Range[Timestamptz]]](defaultMap, "tstzmultirange")
|
registerDefaultPgTypeVariants[Multirange[Range[Timestamptz]]](defaultMap, "tstzmultirange")
|
||||||
registerDefaultPgTypeVariants[UUID](defaultMap, "uuid")
|
registerDefaultPgTypeVariants[UUID](defaultMap, "uuid")
|
||||||
|
|
||||||
|
defaultMap.buildReflectTypeToType()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue