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

Method EquivalentOrNull

postgres/parser/types/types.go:1778–1812  ·  view source on GitHub ↗

EquivalentOrNull is the same as Equivalent, except it returns true if: * `t` is Unknown (i.e., NULL) and `other` is not a tuple, * `t` is a tuple with all non-Unknown elements matching the types in `other`.

(other *T)

Source from the content-addressed store, hash-verified

1776// * `t` is Unknown (i.e., NULL) and `other` is not a tuple,
1777// * `t` is a tuple with all non-Unknown elements matching the types in `other`.
1778func (t *T) EquivalentOrNull(other *T) bool {
1779 // Check normal equivalency first, then check for Null
1780 normalEquivalency := t.Equivalent(other)
1781 if normalEquivalency {
1782 return true
1783 }
1784
1785 switch t.Family() {
1786 case UnknownFamily:
1787 return other.Family() != TupleFamily
1788
1789 case TupleFamily:
1790 if other.Family() != TupleFamily {
1791 return false
1792 }
1793 // If either tuple is the wildcard tuple, it's equivalent to any other
1794 // tuple type. This allows overloads to specify that they take an arbitrary
1795 // tuple type.
1796 if IsWildcardTupleType(t) || IsWildcardTupleType(other) {
1797 return true
1798 }
1799 if len(t.TupleContents()) != len(other.TupleContents()) {
1800 return false
1801 }
1802 for i := range t.TupleContents() {
1803 if !t.TupleContents()[i].EquivalentOrNull(other.TupleContents()[i]) {
1804 return false
1805 }
1806 }
1807 return true
1808
1809 default:
1810 return normalEquivalency
1811 }
1812}
1813
1814// Identical returns true if every field in this ColumnType is exactly the same
1815// as every corresponding field in the given ColumnType. Identical performs a

Callers 1

typeCheckSubqueryWithInFunction · 0.80

Calls 4

EquivalentMethod · 0.95
FamilyMethod · 0.95
TupleContentsMethod · 0.95
IsWildcardTupleTypeFunction · 0.85

Tested by

no test coverage detected