mirror of https://github.com/go-gorm/gorm.git
Add Joins
This commit is contained in:
parent
a158d1ada0
commit
5fce17543a
|
@ -128,6 +128,7 @@ func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joins specify Joins conditions
|
// Joins specify Joins conditions
|
||||||
|
// db.Joins("Account").Find(&user)
|
||||||
// db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "jinzhu@example.org").Find(&user)
|
// db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "jinzhu@example.org").Find(&user)
|
||||||
func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
|
func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
|
||||||
tx = db.getInstance()
|
tx = db.getInstance()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package clause
|
||||||
|
|
||||||
|
// Joins joins clause
|
||||||
|
type Joins struct {
|
||||||
|
Name string
|
||||||
|
Query string
|
||||||
|
Vars []interface{}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestJoins(t *testing.T, db *gorm.DB) {
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ func RunTestsSuit(t *testing.T, db *gorm.DB) {
|
||||||
TestDelete(t, db)
|
TestDelete(t, db)
|
||||||
|
|
||||||
TestGroupBy(t, db)
|
TestGroupBy(t, db)
|
||||||
|
TestJoins(t, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreate(t *testing.T, db *gorm.DB) {
|
func TestCreate(t *testing.T, db *gorm.DB) {
|
||||||
|
|
Loading…
Reference in New Issue