Skip to content

Commit 6ea7cd5

Browse files
committed
add impl docs
1 parent f96a527 commit 6ea7cd5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sql/expression/function/oct.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,30 @@ type Oct struct {
2929
var _ sql.FunctionExpression = (*Oct)(nil)
3030
var _ sql.CollationCoercible = (*Oct)(nil)
3131

32+
// NewOct returns a new Oct expression.
3233
func NewOct(n sql.Expression) sql.Expression { return &Oct{n} }
3334

35+
// FunctionName implements sql.FunctionExpression.
3436
func (o *Oct) FunctionName() string {
3537
return "oct"
3638
}
3739

40+
// Description implements sql.FunctionExpression.
3841
func (o *Oct) Description() string {
3942
return "returns a string representation for octal value of N, where N is a decimal number."
4043
}
4144

45+
// Type implements the Expression interface.
4246
func (o *Oct) Type() sql.Type {
4347
return types.LongText
4448
}
4549

50+
// IsNullable implements the Expression interface.
4651
func (o *Oct) IsNullable() bool {
4752
return o.n.IsNullable()
4853
}
4954

55+
// Eval implements the Expression interface.
5056
func (o *Oct) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
5157
// Convert a decimal (base 10) number to octal (base 8)
5258
return NewConv(
@@ -56,14 +62,17 @@ func (o *Oct) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
5662
).Eval(ctx, row)
5763
}
5864

65+
// Resolved implements the Expression interface.
5966
func (o *Oct) Resolved() bool {
6067
return o.n.Resolved()
6168
}
6269

70+
// Children implements the Expression interface.
6371
func (o *Oct) Children() []sql.Expression {
6472
return []sql.Expression{o.n}
6573
}
6674

75+
// WithChildren implements the Expression interface.
6776
func (o *Oct) WithChildren(children ...sql.Expression) (sql.Expression, error) {
6877
if len(children) != 1 {
6978
return nil, sql.ErrInvalidChildrenNumber.New(o, len(children), 1)
@@ -75,6 +84,7 @@ func (o *Oct) String() string {
7584
return fmt.Sprintf("%s(%s)", o.FunctionName(), o.n)
7685
}
7786

87+
// CollationCoercibility implements the interface sql.CollationCoercible.
7888
func (*Oct) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
7989
return ctx.GetCollation(), 4 // strings with collations
8090
}

sql/expression/function/oct_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package function

0 commit comments

Comments
 (0)