2017-04-06 20:47:25 -05:00
|
|
|
// 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
|
|
|
|
|
2019-06-23 10:22:43 -05:00
|
|
|
import "xorm.io/builder"
|
2017-04-06 20:47:25 -05:00
|
|
|
|
|
|
|
// 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 {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.SQL(query, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where provides custom query condition.
|
|
|
|
func (session *Session) Where(query interface{}, args ...interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.Where(query, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// And provides custom query condition.
|
|
|
|
func (session *Session) And(query interface{}, args ...interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.And(query, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// Or provides custom query condition.
|
|
|
|
func (session *Session) Or(query interface{}, args ...interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.Or(query, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID provides converting id as a query condition
|
|
|
|
func (session *Session) ID(id interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.ID(id)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// In provides a query string like "id in (1, 2, 3)"
|
|
|
|
func (session *Session) In(column string, args ...interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.In(column, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotIn provides a query string like "id in (1, 2, 3)"
|
|
|
|
func (session *Session) NotIn(column string, args ...interface{}) *Session {
|
2017-08-22 06:39:52 -05:00
|
|
|
session.statement.NotIn(column, args...)
|
2017-04-06 20:47:25 -05:00
|
|
|
return session
|
|
|
|
}
|
|
|
|
|
2017-08-22 06:39:52 -05:00
|
|
|
// Conds returns session query conditions except auto bean conditions
|
2017-04-06 20:47:25 -05:00
|
|
|
func (session *Session) Conds() builder.Cond {
|
2020-03-22 10:12:55 -05:00
|
|
|
return session.statement.Conds()
|
2017-04-06 20:47:25 -05:00
|
|
|
}
|