Source File
joins.go
Belonging Package
gorm.io/gorm/clause
package clauseimporttype JoinType stringconst (CrossJoin JoinType = "CROSS"InnerJoin JoinType = "INNER"LeftJoin JoinType = "LEFT"RightJoin JoinType = "RIGHT")type JoinTarget struct {Type JoinTypeAssociation stringSubquery ExpressionTable string}func ( string) JoinTarget {return JoinTarget{Type: InnerJoin, Association: }}func ( JoinType) ( string) JoinTarget {return JoinTarget{Type: , Association: }}func ( JoinType) ( string, Expression) JoinTarget {return JoinTarget{Type: , Association: , Subquery: }}func ( JoinTarget) ( string) JoinTarget {.Table =return}// Join clause for fromtype Join struct {Type JoinTypeTable TableON WhereUsing []stringExpression Expression}func ( ...string) Table {return Table{Name: utils.JoinNestedRelationNames(),}}func ( Join) ( Builder) {if .Expression != nil {.Expression.Build()} else {if .Type != "" {.WriteString(string(.Type)).WriteByte(' ')}.WriteString("JOIN ").WriteQuoted(.Table)if len(.ON.Exprs) > 0 {.WriteString(" ON ").ON.Build()} else if len(.Using) > 0 {.WriteString(" USING (")for , := range .Using {if > 0 {.WriteByte(',')}.WriteQuoted()}.WriteByte(')')}}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |