Skip to content

Commit

Permalink
Bail out of Flush if it’s already been called.
Browse files Browse the repository at this point in the history
If there’s nothing for Flush to do, then just bail out. This makes sure
it’s safe to call Flush multiple times.
  • Loading branch information
paddycarver committed Jul 26, 2016
1 parent a3a749a commit 5d3855a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (q *Query) PostgreSQLString() (string, error) {
// `join`, then added onto the Query’s SQL string, with a space between the SQL string
// and the expressions.
func (q *Query) Flush(join string) *Query {
if len(q.expressions) < 1 {
return q
}
q.sql = strings.TrimSpace(q.sql) + " "
q.sql += strings.TrimSpace(strings.Join(q.expressions, join))
q.expressions = q.expressions[0:0]
Expand Down

0 comments on commit 5d3855a

Please sign in to comment.