session_cond.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import "github.com/xormplus/builder"
  6. // Sql provides raw sql input parameter. When you have a complex SQL statement
  7. // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
  8. //
  9. // Deprecated: use SQL instead.
  10. func (session *Session) Sql(query interface{}, args ...interface{}) *Session {
  11. return session.SQL(query, args...)
  12. }
  13. // SQL provides raw sql input parameter. When you have a complex SQL statement
  14. // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
  15. func (session *Session) SQL(query interface{}, args ...interface{}) *Session {
  16. session.isSqlFunc = true
  17. session.statement.SQL(query, args...)
  18. return session
  19. }
  20. // Where provides custom query condition.
  21. func (session *Session) Where(query interface{}, args ...interface{}) *Session {
  22. session.statement.Where(query, args...)
  23. return session
  24. }
  25. // And provides custom query condition.
  26. func (session *Session) And(query interface{}, args ...interface{}) *Session {
  27. session.statement.And(query, args...)
  28. return session
  29. }
  30. // Or provides custom query condition.
  31. func (session *Session) Or(query interface{}, args ...interface{}) *Session {
  32. session.statement.Or(query, args...)
  33. return session
  34. }
  35. // Id provides converting id as a query condition
  36. //
  37. // Deprecated: use ID instead
  38. func (session *Session) Id(id interface{}) *Session {
  39. return session.ID(id)
  40. }
  41. // ID provides converting id as a query condition
  42. func (session *Session) ID(id interface{}) *Session {
  43. session.statement.ID(id)
  44. return session
  45. }
  46. // In provides a query string like "id in (1, 2, 3)"
  47. func (session *Session) In(column string, args ...interface{}) *Session {
  48. session.statement.In(column, args...)
  49. return session
  50. }
  51. // NotIn provides a query string like "id in (1, 2, 3)"
  52. func (session *Session) NotIn(column string, args ...interface{}) *Session {
  53. session.statement.NotIn(column, args...)
  54. return session
  55. }
  56. // Conds returns session query conditions except auto bean conditions
  57. func (session *Session) Conds() builder.Cond {
  58. return session.statement.cond
  59. }