github.com/friesencr/pop/v6@v6.1.6/query_joins.go (about)

     1  package pop
     2  
     3  import (
     4  	"github.com/friesencr/pop/v6/logging"
     5  )
     6  
     7  // Join will append a JOIN clause to the query
     8  func (q *Query) Join(table string, on string, args ...interface{}) *Query {
     9  	if q.RawSQL.Fragment != "" {
    10  		log(logging.Warn, "Query is setup to use raw SQL")
    11  		return q
    12  	}
    13  	q.joinClauses = append(q.joinClauses, joinClause{"JOIN", table, on, args})
    14  	return q
    15  }
    16  
    17  // LeftJoin will append a LEFT JOIN clause to the query
    18  func (q *Query) LeftJoin(table string, on string, args ...interface{}) *Query {
    19  	if q.RawSQL.Fragment != "" {
    20  		log(logging.Warn, "Query is setup to use raw SQL")
    21  		return q
    22  	}
    23  	q.joinClauses = append(q.joinClauses, joinClause{"LEFT JOIN", table, on, args})
    24  	return q
    25  }
    26  
    27  // RightJoin will append a RIGHT JOIN clause to the query
    28  func (q *Query) RightJoin(table string, on string, args ...interface{}) *Query {
    29  	if q.RawSQL.Fragment != "" {
    30  		log(logging.Warn, "Query is setup to use raw SQL")
    31  		return q
    32  	}
    33  	q.joinClauses = append(q.joinClauses, joinClause{"RIGHT JOIN", table, on, args})
    34  	return q
    35  }
    36  
    37  // LeftOuterJoin will append a LEFT OUTER JOIN clause to the query
    38  func (q *Query) LeftOuterJoin(table string, on string, args ...interface{}) *Query {
    39  	if q.RawSQL.Fragment != "" {
    40  		log(logging.Warn, "Query is setup to use raw SQL")
    41  		return q
    42  	}
    43  	q.joinClauses = append(q.joinClauses, joinClause{"LEFT OUTER JOIN", table, on, args})
    44  	return q
    45  }
    46  
    47  // RightOuterJoin will append a RIGHT OUTER JOIN clause to the query
    48  func (q *Query) RightOuterJoin(table string, on string, args ...interface{}) *Query {
    49  	if q.RawSQL.Fragment != "" {
    50  		log(logging.Warn, "Query is setup to use raw SQL")
    51  		return q
    52  	}
    53  	q.joinClauses = append(q.joinClauses, joinClause{"RIGHT OUTER JOIN", table, on, args})
    54  	return q
    55  }
    56  
    57  // InnerJoin will append an INNER JOIN clause to the query
    58  func (q *Query) InnerJoin(table string, on string, args ...interface{}) *Query {
    59  	if q.RawSQL.Fragment != "" {
    60  		log(logging.Warn, "Query is setup to use raw SQL")
    61  		return q
    62  	}
    63  	q.joinClauses = append(q.joinClauses, joinClause{"INNER JOIN", table, on, args})
    64  	return q
    65  }