-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalue_expressions.go
More file actions
50 lines (39 loc) · 955 Bytes
/
value_expressions.go
File metadata and controls
50 lines (39 loc) · 955 Bytes
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
41
42
43
44
45
46
47
48
49
50
package expressions
import (
"fmt"
"time"
)
var _ Expression = (*Scalar)(nil)
var _ Expression = (*Timestamp)(nil)
// Scalar represents a scalar value used in an expression.
type Scalar struct {
value any
}
// NewScalar creates a new [Scalar] expression.
func NewScalar(value any) *Scalar {
return &Scalar{
value: value,
}
}
func (s Scalar) Operands() []Expression {
return nil
}
// Value returns the scalar value represented by [Scalar].
func (s Scalar) Value() any {
return s.value
}
func (s Scalar) String() string {
return fmt.Sprintf("%#v", s.value)
}
// Timestamp represents a timestamp value used in an expression.
type Timestamp time.Time
// NewTimestamp creates a new [Timestamp] expression.
func NewTimestamp(value time.Time) Timestamp {
return Timestamp(value)
}
func (t Timestamp) Operands() []Expression {
return nil
}
func (t Timestamp) String() string {
return fmt.Sprintf("%v", time.Time(t).Format(time.RFC3339))
}