Fixes and improvements

This commit is contained in:
Shtorm
2026-07-16 11:16:10 +03:00
parent a27453e4f7
commit 4624fd51b1
28 changed files with 1178 additions and 1474 deletions

29
common/sql/json.go Normal file
View File

@@ -0,0 +1,29 @@
package sql
import (
"encoding/json"
"fmt"
)
type SliceJSON[T any] []T
func (s *SliceJSON[T]) Scan(src interface{}) error {
if src == nil {
*s = nil
return nil
}
var data []byte
switch v := src.(type) {
case []byte:
data = v
case string:
data = []byte(v)
default:
return fmt.Errorf("sliceJSON.Scan: unsupported type %T", src)
}
if len(data) == 0 {
*s = nil
return nil
}
return json.Unmarshal(data, (*[]T)(s))
}