-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty.go
40 lines (33 loc) · 852 Bytes
/
property.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
33
34
35
36
37
38
39
40
package sqlf
// Property is the interface for properties.
type Property interface {
FragmentBuilder
// Used reports if the property is used.
Used() bool
// ReportUsed marks current property as used
ReportUsed()
}
var _ Property = (*defaultProperty)(nil)
type defaultProperty struct {
value FragmentBuilder
used bool
}
// newDefaultProperty returns a new property.
func newDefaultProperty(value FragmentBuilder) *defaultProperty {
return &defaultProperty{
value: value,
}
}
// ReportUsed reports the item is used
func (p *defaultProperty) ReportUsed() {
p.used = true
}
// Used returns true if the column is used.
func (p *defaultProperty) Used() bool {
return p.used
}
// BuildFragment builds the fragment.
func (p *defaultProperty) BuildFragment(ctx *Context) (string, error) {
p.used = true
return p.value.BuildFragment(ctx)
}