Skip to content

Commit

Permalink
add custom join option
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Sep 9, 2024
1 parent 27c29e0 commit 95f448a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions exp/exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ const (
NaturalRightJoinType
NaturalFullJoinType
CrossJoinType
CustomJoinType

UsingJoinCondType JoinConditionType = iota
OnJoinCondType
Expand Down
5 changes: 5 additions & 0 deletions select_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ func (sd *SelectDataset) CrossJoin(table exp.Expression) *SelectDataset {
return sd.joinTable(exp.NewUnConditionedJoinExpression(exp.CrossJoinType, table))
}

// Adds a custom join clause. See examples
func (sd *SelectDataset) CustomJoin(expression exp.Expression) *SelectDataset {
return sd.joinTable(exp.NewUnConditionedJoinExpression(exp.CustomJoinType, expression))
}

// Joins this Datasets table with another
func (sd *SelectDataset) joinTable(join exp.JoinExpression) *SelectDataset {
return sd.copy(sd.clauses.JoinsAppend(join))
Expand Down
1 change: 1 addition & 0 deletions sqlgen/sql_dialect_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ func DefaultDialectOptions() *SQLDialectOptions {
exp.NaturalRightJoinType: []byte(" NATURAL RIGHT JOIN "),
exp.NaturalFullJoinType: []byte(" NATURAL FULL JOIN "),
exp.CrossJoinType: []byte(" CROSS JOIN "),
exp.CustomJoinType: []byte(" "), // User need to fill in the join statement themselves
},

TimeFormat: time.RFC3339Nano,
Expand Down

0 comments on commit 95f448a

Please sign in to comment.