MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Format

Method Format

postgres/parser/sem/tree/expr.go:497–512  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

495
496// Format implements the NodeFormatter interface.
497func (node *ComparisonExpr) Format(ctx *FmtCtx) {
498 opStr := node.Operator.String()
499 // IS and IS NOT are equivalent to IS NOT DISTINCT FROM and IS DISTINCT
500 // FROM, respectively, when the RHS is true or false. We prefer the less
501 // verbose IS and IS NOT in those cases.
502 if node.Operator == IsDistinctFrom && (node.Right == DBoolTrue || node.Right == DBoolFalse) {
503 opStr = "IS NOT"
504 } else if node.Operator == IsNotDistinctFrom && (node.Right == DBoolTrue || node.Right == DBoolFalse) {
505 opStr = "IS"
506 }
507 if node.Operator.HasSubOperator() {
508 binExprFmtWithParenAndSubOp(ctx, node.Left, node.SubOperator.String(), opStr, node.Right)
509 } else {
510 binExprFmtWithParen(ctx, node.Left, opStr, node.Right, true)
511 }
512}
513
514// NewTypedComparisonExpr returns a new ComparisonExpr that is verified to be well-typed.
515func NewTypedComparisonExpr(op ComparisonOperator, left, right TypedExpr) *ComparisonExpr {

Callers

nothing calls this directly

Calls 4

binExprFmtWithParenFunction · 0.85
HasSubOperatorMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected