-
Notifications
You must be signed in to change notification settings - Fork 0
/
infer.go
32 lines (27 loc) · 922 Bytes
/
infer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package squl
import (
"bytes"
stdfmt "fmt"
fmt "golang.org/x/xerrors"
"github.com/trivigy/squl/internal/global"
)
// Infer represents the ON CONFLICT unique index inference clause.
type Infer struct {
IndexElems *List `json:"indexElems"` /* IndexElems to infer unique index */
WhereClause Node `json:"whereClause"` /* qualification (partial-index predicate) */
Conname *string `json:"conname"` /* Constraint name, or NULL if unnamed */
Location int `json:"location"` /* token location, or -1 if unknown */
}
func (r *Infer) dump(counter *ordinalMarker) (string, error) {
buffer := bytes.NewBuffer(nil)
if r.IndexElems != nil {
dump, err := r.IndexElems.dump(counter)
if err != nil {
return "", err
}
if _, err := buffer.WriteString(stdfmt.Sprintf("(%s)", dump)); err != nil {
return "", fmt.Errorf(global.ErrFmt, pkg.Name(), err)
}
}
return buffer.String(), nil
}