Save tags on pool rows, show errors in summary table
This commit is contained in:
parent
123a4bf590
commit
ef569aef18
11 changed files with 305 additions and 172 deletions
32
db/pgdata.go
Normal file
32
db/pgdata.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func ConvertFromPGData(d pgtypes.HStore) map[string]string {
|
||||
result := make(map[string]string, 0)
|
||||
for k, v := range d {
|
||||
value, err := v.Value()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Str("key", k).Msg("Failed to convert from HSTORE")
|
||||
continue
|
||||
}
|
||||
value_str, ok := value.(string)
|
||||
if !ok {
|
||||
log.Warn().Msg("Failed to convert to string")
|
||||
}
|
||||
result[k] = value_str
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ConvertToPGData(data map[string]string) pgtypes.HStore {
|
||||
result := pgtypes.HStore{}
|
||||
for k, v := range data {
|
||||
result[k] = sql.Null[string]{V: v, Valid: true}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue