mirror of
https://github.com/harness/drone.git
synced 2025-05-06 02:40:52 +08:00
22 lines
650 B
Go
22 lines
650 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package database
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
sqlx "github.com/jmoiron/sqlx/types"
|
|
)
|
|
|
|
// EncodeToSQLXJSON accepts a generic parameter and returns
|
|
// a sqlx.JSONText object which is used to store arbitrary
|
|
// data in the DB. We absorb the error here as the value
|
|
// gets absorbed in sqlx.JSONText in case of UnsupportedValueError
|
|
// or UnsupportedTypeError.
|
|
func EncodeToSQLXJSON(v any) sqlx.JSONText {
|
|
raw, _ := json.Marshal(v)
|
|
return sqlx.JSONText(raw)
|
|
}
|