summaryrefslogtreecommitdiffstats
path: root/vendor/xorm.io/xorm/schemas/pk.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/xorm.io/xorm/schemas/pk.go')
-rw-r--r--vendor/xorm.io/xorm/schemas/pk.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/vendor/xorm.io/xorm/schemas/pk.go b/vendor/xorm.io/xorm/schemas/pk.go
index 03916b44fd..da3c7899b3 100644
--- a/vendor/xorm.io/xorm/schemas/pk.go
+++ b/vendor/xorm.io/xorm/schemas/pk.go
@@ -11,13 +11,16 @@ import (
"xorm.io/xorm/internal/utils"
)
+// PK represents primary key values
type PK []interface{}
+// NewPK creates primay keys
func NewPK(pks ...interface{}) *PK {
p := PK(pks)
return &p
}
+// IsZero return true if primay keys are zero
func (p *PK) IsZero() bool {
for _, k := range *p {
if utils.IsZero(k) {
@@ -27,6 +30,7 @@ func (p *PK) IsZero() bool {
return false
}
+// ToString convert to SQL string
func (p *PK) ToString() (string, error) {
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
@@ -34,6 +38,7 @@ func (p *PK) ToString() (string, error) {
return buf.String(), err
}
+// FromString reads content to load primary keys
func (p *PK) FromString(content string) error {
dec := gob.NewDecoder(bytes.NewBufferString(content))
err := dec.Decode(p)