MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / isNumericOne

Method isNumericOne

pkg/sql/sem/tree/normalize.go:780–792  ·  view source on GitHub ↗

isNumericOne returns true if the datum is a number and equal to one.

(expr TypedExpr)

Source from the content-addressed store, hash-verified

778// isNumericOne returns true if the datum is a number and equal to
779// one.
780func (v *NormalizeVisitor) isNumericOne(expr TypedExpr) bool {
781 if d, ok := expr.(Datum); ok {
782 switch t := UnwrapDatum(v.ctx, d).(type) {
783 case *DDecimal:
784 return t.Decimal.Cmp(&DecimalOne.Decimal) == 0
785 case *DFloat:
786 return *t == 1.0
787 case *DInt:
788 return *t == 1
789 }
790 }
791 return false
792}
793
794func invertComparisonOp(op ComparisonOperator) (ComparisonOperator, error) {
795 switch op {

Callers 1

normalizeMethod · 0.80

Calls 1

UnwrapDatumFunction · 0.85

Tested by

no test coverage detected