parent
e8fbd41c16
commit
382b85d765
64
session.go
64
session.go
|
@ -16,7 +16,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-xorm/builder"
|
||||
"github.com/go-xorm/core"
|
||||
)
|
||||
|
||||
|
@ -113,52 +112,6 @@ func (session *Session) Prepare() *Session {
|
|||
return session
|
||||
}
|
||||
|
||||
// Sql provides raw sql input parameter. When you have a complex SQL statement
|
||||
// and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
|
||||
//
|
||||
// Deprecated: use SQL instead.
|
||||
func (session *Session) Sql(query string, args ...interface{}) *Session {
|
||||
return session.SQL(query, args...)
|
||||
}
|
||||
|
||||
// SQL provides raw sql input parameter. When you have a complex SQL statement
|
||||
// and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
|
||||
func (session *Session) SQL(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.SQL(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Where provides custom query condition.
|
||||
func (session *Session) Where(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.Where(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// And provides custom query condition.
|
||||
func (session *Session) And(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.And(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Or provides custom query condition.
|
||||
func (session *Session) Or(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.Or(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Id provides converting id as a query condition
|
||||
//
|
||||
// Deprecated: use ID instead
|
||||
func (session *Session) Id(id interface{}) *Session {
|
||||
return session.ID(id)
|
||||
}
|
||||
|
||||
// ID provides converting id as a query condition
|
||||
func (session *Session) ID(id interface{}) *Session {
|
||||
session.Statement.ID(id)
|
||||
return session
|
||||
}
|
||||
|
||||
// Before Apply before Processor, affected bean is passed to closure arg
|
||||
func (session *Session) Before(closures func(interface{})) *Session {
|
||||
if closures != nil {
|
||||
|
@ -187,18 +140,6 @@ func (session *Session) Alias(alias string) *Session {
|
|||
return session
|
||||
}
|
||||
|
||||
// In provides a query string like "id in (1, 2, 3)"
|
||||
func (session *Session) In(column string, args ...interface{}) *Session {
|
||||
session.Statement.In(column, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// NotIn provides a query string like "id in (1, 2, 3)"
|
||||
func (session *Session) NotIn(column string, args ...interface{}) *Session {
|
||||
session.Statement.NotIn(column, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Incr provides a query string like "count = count + 1"
|
||||
func (session *Session) Incr(column string, arg ...interface{}) *Session {
|
||||
session.Statement.Incr(column, arg...)
|
||||
|
@ -375,11 +316,6 @@ func (session *Session) DB() *core.DB {
|
|||
return session.db
|
||||
}
|
||||
|
||||
// Conds returns session query conditions
|
||||
func (session *Session) Conds() builder.Cond {
|
||||
return session.Statement.cond
|
||||
}
|
||||
|
||||
func cleanupProcessorsClosures(slices *[]func(interface{})) {
|
||||
if len(*slices) > 0 {
|
||||
*slices = make([]func(interface{}), 0)
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright 2017 The Xorm Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package xorm
|
||||
|
||||
import "github.com/go-xorm/builder"
|
||||
|
||||
// Sql provides raw sql input parameter. When you have a complex SQL statement
|
||||
// and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
|
||||
//
|
||||
// Deprecated: use SQL instead.
|
||||
func (session *Session) Sql(query string, args ...interface{}) *Session {
|
||||
return session.SQL(query, args...)
|
||||
}
|
||||
|
||||
// SQL provides raw sql input parameter. When you have a complex SQL statement
|
||||
// and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
|
||||
func (session *Session) SQL(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.SQL(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Where provides custom query condition.
|
||||
func (session *Session) Where(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.Where(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// And provides custom query condition.
|
||||
func (session *Session) And(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.And(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Or provides custom query condition.
|
||||
func (session *Session) Or(query interface{}, args ...interface{}) *Session {
|
||||
session.Statement.Or(query, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Id provides converting id as a query condition
|
||||
//
|
||||
// Deprecated: use ID instead
|
||||
func (session *Session) Id(id interface{}) *Session {
|
||||
return session.ID(id)
|
||||
}
|
||||
|
||||
// ID provides converting id as a query condition
|
||||
func (session *Session) ID(id interface{}) *Session {
|
||||
session.Statement.ID(id)
|
||||
return session
|
||||
}
|
||||
|
||||
// In provides a query string like "id in (1, 2, 3)"
|
||||
func (session *Session) In(column string, args ...interface{}) *Session {
|
||||
session.Statement.In(column, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// NotIn provides a query string like "id in (1, 2, 3)"
|
||||
func (session *Session) NotIn(column string, args ...interface{}) *Session {
|
||||
session.Statement.NotIn(column, args...)
|
||||
return session
|
||||
}
|
||||
|
||||
// Conds returns session query conditions
|
||||
func (session *Session) Conds() builder.Cond {
|
||||
return session.Statement.cond
|
||||
}
|
12
statement.go
12
statement.go
|
@ -195,10 +195,6 @@ func (statement *Statement) Or(query interface{}, args ...interface{}) *Statemen
|
|||
|
||||
// In generate "Where column IN (?) " statement
|
||||
func (statement *Statement) In(column string, args ...interface{}) *Statement {
|
||||
if len(args) == 0 {
|
||||
return statement
|
||||
}
|
||||
|
||||
in := builder.In(column, args...)
|
||||
statement.cond = statement.cond.And(in)
|
||||
return statement
|
||||
|
@ -206,12 +202,8 @@ func (statement *Statement) In(column string, args ...interface{}) *Statement {
|
|||
|
||||
// NotIn generate "Where column NOT IN (?) " statement
|
||||
func (statement *Statement) NotIn(column string, args ...interface{}) *Statement {
|
||||
if len(args) == 0 {
|
||||
return statement
|
||||
}
|
||||
|
||||
in := builder.NotIn(column, args...)
|
||||
statement.cond = statement.cond.And(in)
|
||||
notIn := builder.NotIn(column, args...)
|
||||
statement.cond = statement.cond.And(notIn)
|
||||
return statement
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue