本文整理匯總了Golang中github.com/cockroachdb/cockroach/sql/sqlwire.Datum.ToString方法的典型用法代碼示例。如果您正苦於以下問題:Golang Datum.ToString方法的具體用法?Golang Datum.ToString怎麽用?Golang Datum.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/sql/sqlwire.Datum
的用法示例。
在下文中一共展示了Datum.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: prepareComparisonArgs
// Prepare the arguments for a comparison operation. The returned arguments
// will have the same type.
func prepareComparisonArgs(left, right sqlwire.Datum) (opType, sqlwire.Datum, sqlwire.Datum, error) {
// If both arguments are strings (or string-like), compare as strings.
if (left.BytesVal != nil || left.StringVal != nil) &&
(right.BytesVal != nil || right.StringVal != nil) {
return stringOp, left.ToString(), right.ToString(), nil
}
// If both arguments are uints, compare as unsigned.
if left.UintVal != nil && right.UintVal != nil {
return uintOp, left, right, nil
}
var err error
// If both arguments are integers (signed or unsigned), compare as integers.
if (left.BoolVal != nil || left.IntVal != nil || left.UintVal != nil) &&
(right.BoolVal != nil || right.IntVal != nil || right.UintVal != nil) {
left, err = left.ToInt()
if err != nil {
return intOp, null, null, err
}
right, err = right.ToInt()
if err != nil {
return intOp, null, null, err
}
return intOp, left, right, nil
}
// In all other cases, compare as floats.
left, err = left.ToFloat()
if err != nil {
return intOp, null, null, err
}
right, err = right.ToFloat()
if err != nil {
return intOp, null, null, err
}
return floatOp, left, right, nil
}