Feat v0.3.5 settings icd clone #19
@@ -14,17 +14,19 @@ import (
|
||||
"switchboard-core/store/sqlite"
|
||||
)
|
||||
|
||||
// jsonEq compares two JSON byte slices ignoring whitespace differences
|
||||
// (PG JSONB normalizes spacing, SQLite preserves it verbatim).
|
||||
// jsonEq compares two JSON byte slices ignoring whitespace and key order
|
||||
// (PG JSONB normalizes spacing and may reorder keys).
|
||||
func jsonEq(a, b json.RawMessage) bool {
|
||||
var ca, cb bytes.Buffer
|
||||
if err := json.Compact(&ca, a); err != nil {
|
||||
var va, vb interface{}
|
||||
if err := json.Unmarshal(a, &va); err != nil {
|
||||
return false
|
||||
}
|
||||
if err := json.Compact(&cb, b); err != nil {
|
||||
if err := json.Unmarshal(b, &vb); err != nil {
|
||||
return false
|
||||
}
|
||||
return ca.String() == cb.String()
|
||||
na, _ := json.Marshal(va)
|
||||
nb, _ := json.Marshal(vb)
|
||||
return bytes.Equal(na, nb)
|
||||
}
|
||||
|
||||
// testStores returns an appropriate Stores for the current dialect.
|
||||
|
||||
Reference in New Issue
Block a user