summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-pg/pg/v10/orm/table_params.go
blob: 46d8e064a6e93857515ad9e841306488239b6241 (plain)
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
package orm

import "reflect"

type tableParams struct {
	table *Table
	strct reflect.Value
}

func newTableParams(strct interface{}) (*tableParams, bool) {
	v := reflect.ValueOf(strct)
	if !v.IsValid() {
		return nil, false
	}

	v = reflect.Indirect(v)
	if v.Kind() != reflect.Struct {
		return nil, false
	}

	return &tableParams{
		table: GetTable(v.Type()),
		strct: v,
	}, true
}

func (m *tableParams) AppendParam(fmter QueryFormatter, b []byte, name string) ([]byte, bool) {
	return m.table.AppendParam(b, m.strct, name)
}