Skip to content

Commit

Permalink
Merge pull request #7 from liquidm/citext-compatibility
Browse files Browse the repository at this point in the history
Add citext to known oids to prevent warning message
  • Loading branch information
furbanowicz-smartadserver authored Feb 23, 2023
2 parents 8288244 + 7b8953c commit b603fcd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions values_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var (
ErrUnknownOID = errors.New("Unknown OID")
)

//ValuesMap is used in Converter interface.
//It has true set to every oid which is value type in database.
// ValuesMap is used in Converter interface.
// It has true set to every oid which is value type in database.
type ValuesMap map[int]bool

func loadValuesMap(dbConfig *DatabaseConfig) (ValuesMap, error) {
Expand All @@ -25,8 +25,8 @@ func loadValuesMap(dbConfig *DatabaseConfig) (ValuesMap, error) {
return valuesMap, nil
}

//Extract value from DatumMessage. Returned value is always a pointer.
//Returns ErrUnknownOID if value is of unonkown OID. If returned with error, value is []byte or nil.
// Extract value from DatumMessage. Returned value is always a pointer.
// Returns ErrUnknownOID if value is of unonkown OID. If returned with error, value is []byte or nil.
func (v ValuesMap) Extract(m *decoderbufs.DatumMessage) (interface{}, error) {
var err error
var value interface{}
Expand Down Expand Up @@ -69,7 +69,11 @@ func (v ValuesMap) load(dbConfig *DatabaseConfig) error {
}
defer db.Close()

oidQueries := []string{"SELECT enumtypid FROM pg_enum;", "SELECT DISTINCT typarray FROM pg_type WHERE typarray > 0;"}
oidQueries := []string{
"SELECT enumtypid FROM pg_enum;",
"SELECT DISTINCT typarray FROM pg_type WHERE typarray > 0;",
"SELECT oid FROM pg_type WHERE typname = 'citext'",
}
for _, query := range oidQueries {
rows, err := db.Query(query)
if err != nil {
Expand Down

0 comments on commit b603fcd

Please sign in to comment.