summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/schema/relation.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/schema/relation.go')
-rw-r--r--vendor/github.com/uptrace/bun/schema/relation.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/vendor/github.com/uptrace/bun/schema/relation.go b/vendor/github.com/uptrace/bun/schema/relation.go
index 6636e26a6..9eb74f7e9 100644
--- a/vendor/github.com/uptrace/bun/schema/relation.go
+++ b/vendor/github.com/uptrace/bun/schema/relation.go
@@ -30,6 +30,12 @@ type Relation struct {
M2MJoinFields []*Field
}
+// References returns true if the table to which the Relation belongs needs to declare a foreign key constraint to create the relation.
+// For other relations, the constraint is created in either the referencing table (1:N, 'has-many' relations) or a mapping table (N:N, 'm2m' relations).
+func (r *Relation) References() bool {
+ return r.Type == HasOneRelation || r.Type == BelongsToRelation
+}
+
func (r *Relation) String() string {
return fmt.Sprintf("relation=%s", r.Field.GoName)
}