本文整理匯總了Golang中github.com/cockroachdb/cockroach/sql/parser.ComparisonExpr.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang ComparisonExpr.String方法的具體用法?Golang ComparisonExpr.String怎麽用?Golang ComparisonExpr.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/sql/parser.ComparisonExpr
的用法示例。
在下文中一共展示了ComparisonExpr.String方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encodeStartConstraintDescending
func encodeStartConstraintDescending(
spans []span, c *parser.ComparisonExpr) {
switch c.Operator {
case parser.Is:
// An IS NULL expressions allows us to constrain the start of the range
// to begin at NULL.
if c.Right != parser.DNull {
panic("Expected NULL operand for IS operator.")
}
for i := range spans {
spans[i].start = encoding.EncodeNullDescending(spans[i].start)
}
case parser.LE, parser.EQ:
if datum, ok := c.Right.(parser.Datum); ok {
key, pErr := encodeTableKey(nil, datum, encoding.Descending)
if pErr != nil {
panic(pErr)
}
// Append the constraint to all of the existing spans.
for i := range spans {
spans[i].start = append(spans[i].start, key...)
}
}
case parser.LT:
// A "<" constraint is the last start constraint. Since the constraint
// is exclusive and the start key is inclusive, we're going to apply
// a .PrefixEnd().
if datum, ok := c.Right.(parser.Datum); ok {
key, pErr := encodeTableKey(nil, datum, encoding.Descending)
if pErr != nil {
panic(pErr)
}
// Append the constraint to all of the existing spans.
for i := range spans {
spans[i].start = append(spans[i].start, key...)
spans[i].start = spans[i].start.PrefixEnd()
}
}
default:
panic(fmt.Errorf("unexpected operator: %s", c.String()))
}
}
示例2: encodeEndConstraintDescending
func encodeEndConstraintDescending(spans []span, c *parser.ComparisonExpr,
isLastEndConstraint bool) {
switch c.Operator {
case parser.IsNot:
// An IS NULL expressions allows us to constrain the end of the range
// to stop at NULL.
if c.Right != parser.DNull {
panic("Expected NULL operand for IS NOT operator.")
}
for i := range spans {
spans[i].end = encoding.EncodeNotNullDescending(spans[i].end)
}
case parser.GE, parser.EQ:
datum := c.Right.(parser.Datum)
for i := range spans {
spans[i].end = encodeInclusiveEndValue(
spans[i].end, datum, encoding.Descending, isLastEndConstraint)
}
case parser.GT:
panic("'>' operators should have been transformed to '>='.")
default:
panic(fmt.Errorf("unexpected operator: %s", c.String()))
}
}