Equivalent returns true if this type is "equivalent" to the given type. Equivalent types are compatible with one another: they can be compared, assigned, and unioned. Equivalent types must always have the same type family for the root type and any descendant types (i.e. in case of array or tuple typ
(other *T)
| 1414 | // behavior. AnyFamily types match any other type, including other AnyFamily |
| 1415 | // types. And a wildcard collation (empty string) matches any other collation. |
| 1416 | func (t *T) Equivalent(other *T) bool { |
| 1417 | if t.Family() == AnyFamily || other.Family() == AnyFamily { |
| 1418 | return true |
| 1419 | } |
| 1420 | if t.Family() != other.Family() { |
| 1421 | return false |
| 1422 | } |
| 1423 | |
| 1424 | switch t.Family() { |
| 1425 | case CollatedStringFamily: |
| 1426 | if t.Locale() != "" && other.Locale() != "" && t.Locale() != other.Locale() { |
| 1427 | return false |
| 1428 | } |
| 1429 | |
| 1430 | case TupleFamily: |
| 1431 | // If either tuple is the wildcard tuple, it's equivalent to any other |
| 1432 | // tuple type. This allows overloads to specify that they take an arbitrary |
| 1433 | // tuple type. |
| 1434 | if IsWildcardTupleType(t) || IsWildcardTupleType(other) { |
| 1435 | return true |
| 1436 | } |
| 1437 | if len(t.TupleContents()) != len(other.TupleContents()) { |
| 1438 | return false |
| 1439 | } |
| 1440 | for i := range t.TupleContents() { |
| 1441 | if !t.TupleContents()[i].Equivalent(&other.TupleContents()[i]) { |
| 1442 | return false |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | case ArrayFamily: |
| 1447 | if !t.ArrayContents().Equivalent(other.ArrayContents()) { |
| 1448 | return false |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | return true |
| 1453 | } |
| 1454 | |
| 1455 | // Identical returns true if every field in this ColumnType is exactly the same |
| 1456 | // as every corresponding field in the given ColumnType. Identical performs a |
no test coverage detected