@@ -29,24 +29,30 @@ type Oct struct {
29
29
var _ sql.FunctionExpression = (* Oct )(nil )
30
30
var _ sql.CollationCoercible = (* Oct )(nil )
31
31
32
+ // NewOct returns a new Oct expression.
32
33
func NewOct (n sql.Expression ) sql.Expression { return & Oct {n } }
33
34
35
+ // FunctionName implements sql.FunctionExpression.
34
36
func (o * Oct ) FunctionName () string {
35
37
return "oct"
36
38
}
37
39
40
+ // Description implements sql.FunctionExpression.
38
41
func (o * Oct ) Description () string {
39
42
return "returns a string representation for octal value of N, where N is a decimal number."
40
43
}
41
44
45
+ // Type implements the Expression interface.
42
46
func (o * Oct ) Type () sql.Type {
43
47
return types .LongText
44
48
}
45
49
50
+ // IsNullable implements the Expression interface.
46
51
func (o * Oct ) IsNullable () bool {
47
52
return o .n .IsNullable ()
48
53
}
49
54
55
+ // Eval implements the Expression interface.
50
56
func (o * Oct ) Eval (ctx * sql.Context , row sql.Row ) (interface {}, error ) {
51
57
// Convert a decimal (base 10) number to octal (base 8)
52
58
return NewConv (
@@ -56,14 +62,17 @@ func (o *Oct) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
56
62
).Eval (ctx , row )
57
63
}
58
64
65
+ // Resolved implements the Expression interface.
59
66
func (o * Oct ) Resolved () bool {
60
67
return o .n .Resolved ()
61
68
}
62
69
70
+ // Children implements the Expression interface.
63
71
func (o * Oct ) Children () []sql.Expression {
64
72
return []sql.Expression {o .n }
65
73
}
66
74
75
+ // WithChildren implements the Expression interface.
67
76
func (o * Oct ) WithChildren (children ... sql.Expression ) (sql.Expression , error ) {
68
77
if len (children ) != 1 {
69
78
return nil , sql .ErrInvalidChildrenNumber .New (o , len (children ), 1 )
@@ -75,6 +84,7 @@ func (o *Oct) String() string {
75
84
return fmt .Sprintf ("%s(%s)" , o .FunctionName (), o .n )
76
85
}
77
86
87
+ // CollationCoercibility implements the interface sql.CollationCoercible.
78
88
func (* Oct ) CollationCoercibility (ctx * sql.Context ) (collation sql.CollationID , coercibility byte ) {
79
89
return ctx .GetCollation (), 4 // strings with collations
80
90
}
0 commit comments