[fix] join sub raw() error
This commit is contained in:
parent
ab201ded50
commit
f186c88c5c
32
builder.go
32
builder.go
@ -434,29 +434,31 @@ func (b *Builder) SelectRaw(expression string, bindings ...[]interface{}) *Build
|
|||||||
|
|
||||||
// CreateSub Creates a subquery and parse it.
|
// CreateSub Creates a subquery and parse it.
|
||||||
func (b *Builder) CreateSub(query interface{}) (string, []interface{}) {
|
func (b *Builder) CreateSub(query interface{}) (string, []interface{}) {
|
||||||
var builder *Builder
|
switch v := query.(type) {
|
||||||
if bT, ok := query.(*Builder); ok {
|
case func(builder *Builder):
|
||||||
builder = bT
|
builder := CloneBuilderWithTable(b)
|
||||||
} else if function, ok := query.(func(builder *Builder)); ok {
|
v(builder)
|
||||||
builder = CloneBuilderWithTable(b)
|
return b.ParseSub(builder)
|
||||||
function(builder)
|
case string, Expression, *Builder:
|
||||||
} else if str, ok := query.(string); ok {
|
return b.ParseSub(v)
|
||||||
return b.ParseSub(str)
|
|
||||||
} else {
|
|
||||||
panic("can not create sub")
|
|
||||||
}
|
}
|
||||||
return b.ParseSub(builder)
|
|
||||||
|
panic("can not create sub")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ParseSub Parse the subquery into SQL and bindings.
|
ParseSub Parse the subquery into SQL and bindings.
|
||||||
*/
|
*/
|
||||||
func (b *Builder) ParseSub(query interface{}) (string, []interface{}) {
|
func (b *Builder) ParseSub(query interface{}) (string, []interface{}) {
|
||||||
if s, ok := query.(string); ok {
|
switch v := query.(type) {
|
||||||
return s, []interface{}{}
|
case string:
|
||||||
} else if builder, ok := query.(*Builder); ok {
|
return v, []interface{}{}
|
||||||
return builder.ToSql(), builder.GetBindings()
|
case Expression:
|
||||||
|
return string(v), []interface{}{}
|
||||||
|
case *Builder:
|
||||||
|
return v.ToSql(), v.GetBindings()
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("A subquery must be a query builder instance, a Closure, or a string.")
|
panic("A subquery must be a query builder instance, a Closure, or a string.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user