Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertPlaceholder(sql, prefix string) (string, error)
- func ConvertToBoundSQL(sql string, args []interface{}) (string, error)
- func ToBoundSQL(cond interface{}) (string, error)
- func ToSQL(cond interface{}) (string, []interface{}, error)
- func WriteMap(w Writer, data map[string]interface{}, op string) error
- type Between
- type Builder
- func Delete(conds ...Cond) *Builder
- func Dialect(dialect string) *Builder
- func Insert(eq ...interface{}) *Builder
- func MsSQL() *Builder
- func MySQL() *Builder
- func Oracle() *Builder
- func Postgres() *Builder
- func SQLite() *Builder
- func Select(cols ...string) *Builder
- func Update(updates ...Cond) *Builder
- func (b *Builder) And(cond Cond) *Builder
- func (b *Builder) CrossJoin(joinTable, joinCond interface{}) *Builder
- func (b *Builder) Delete(conds ...Cond) *Builder
- func (b *Builder) Except(distinctType string, cond *Builder) *Builder
- func (b *Builder) From(subject interface{}, alias ...string) *Builder
- func (b *Builder) FullJoin(joinTable, joinCond interface{}) *Builder
- func (b *Builder) GroupBy(groupby string) *Builder
- func (b *Builder) Having(having string) *Builder
- func (b *Builder) InnerJoin(joinTable, joinCond interface{}) *Builder
- func (b *Builder) Insert(eq ...interface{}) *Builder
- func (b *Builder) Intersect(distinctType string, cond *Builder) *Builder
- func (b *Builder) Into(tableName string) *Builder
- func (b *Builder) Join(joinType string, joinTable, joinCond interface{}) *Builder
- func (b *Builder) LeftJoin(joinTable, joinCond interface{}) *Builder
- func (b *Builder) Limit(limitN int, offset ...int) *Builder
- func (b *Builder) Or(cond Cond) *Builder
- func (b *Builder) OrderBy(orderBy string) *Builder
- func (b *Builder) RightJoin(joinTable, joinCond interface{}) *Builder
- func (b *Builder) Select(cols ...string) *Builder
- func (b *Builder) TableName() string
- func (b *Builder) ToBoundSQL() (string, error)
- func (b *Builder) ToSQL() (string, []interface{}, error)
- func (b *Builder) Union(distinctType string, cond *Builder) *Builder
- func (b *Builder) Update(updates ...Cond) *Builder
- func (b *Builder) Where(cond Cond) *Builder
- func (b *Builder) WriteTo(w Writer) error
- type BytesWriter
- type Cond
- type Decr
- type Eq
- type Gt
- type Gte
- type Incr
- type IsNull
- type Like
- type Lt
- type Lte
- type Neq
- type Not
- type NotNull
- type UpdateCond
- type Writer
Constants ¶
View Source
const ( POSTGRES = "postgres" SQLITE = "sqlite3" MYSQL = "mysql" MSSQL = "mssql" ORACLE = "oracle" UNION = "union" INTERSECT = "intersect" EXCEPT = "except" )
all databasees
Variables ¶
View Source
var ( // ErrNotSupportType not supported SQL type error ErrNotSupportType = errors.New("Not supported SQL type") // ErrNoNotInConditions no NOT IN params error ErrNoNotInConditions = errors.New("No NOT IN conditions") // ErrNoInConditions no IN params error ErrNoInConditions = errors.New("No IN conditions") // ErrNeedMoreArguments need more arguments ErrNeedMoreArguments = errors.New("Need more sql arguments") // ErrNoTableName no table name ErrNoTableName = errors.New("No table indicated") // ErrNoColumnToUpdate no column to update ErrNoColumnToUpdate = errors.New("No column(s) to update") // ErrNoColumnToInsert no column to insert ErrNoColumnToInsert = errors.New("No column(s) to insert") // ErrNotSupportDialectType not supported dialect type error ErrNotSupportDialectType = errors.New("Not supported dialect type") // ErrNotUnexpectedUnionConditions using union in a wrong way ErrNotUnexpectedUnionConditions = errors.New("Unexpected conditional fields in UNION query") // ErrUnsupportedUnionMembers unexpected members in UNION query ErrUnsupportedUnionMembers = errors.New("Unexpected members in UNION query") // ErrUnexpectedSubQuery Unexpected sub-query in SELECT query ErrUnexpectedSubQuery = errors.New("Unexpected sub-query in SELECT query") // ErrDialectNotSetUp dialect is not setup yet ErrDialectNotSetUp = errors.New("Dialect is not setup yet, try to use `Dialect(dbType)` at first") // ErrInvalidLimitation offset or limit is not correct ErrInvalidLimitation = errors.New("Offset or limit is not correct") // ErrUnnamedDerivedTable Every derived table must have its own alias ErrUnnamedDerivedTable = errors.New("Every derived table must have its own alias") // ErrInconsistentDialect Inconsistent dialect in same builder ErrInconsistentDialect = errors.New("Inconsistent dialect in same builder") )
Functions ¶
func ConvertPlaceholder ¶
ConvertPlaceholder replaces the place holder ? to $1, $2 ... or :1, :2 ... according prefix
func ConvertToBoundSQL ¶
ConvertToBoundSQL will convert SQL and args to a bound SQL
func ToBoundSQL ¶
ToBoundSQL convert a builder or conditions to parameters bound SQL
Types ¶
type Between ¶
type Between struct { Col string LessVal interface{} MoreVal interface{} }
Between implmentes between condition
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder describes a SQL statement
func (*Builder) From ¶
From sets from subject(can be a table name in string or a builder pointer) and its alias
func (*Builder) ToBoundSQL ¶
ToBoundSQL generated a bound SQL string
type BytesWriter ¶
BytesWriter implments Writer and save SQL in bytes.Buffer
func (*BytesWriter) Append ¶
func (w *BytesWriter) Append(args ...interface{})
Append appends args to Writer
type Eq ¶
type Eq map[string]interface{}
Eq defines equals conditions
type IsNull ¶
type IsNull [1]string
IsNull defines IS NULL condition
type NotNull ¶
type NotNull [1]string
NotNull defines NOT NULL condition
type UpdateCond ¶
UpdateCond defines an interface that cond could be used with update
Source Files ¶
- builder.go
- builder_delete.go
- builder_insert.go
- builder_join.go
- builder_limit.go
- builder_select.go
- builder_set_operations.go
- builder_update.go
- cond.go
- cond_and.go
- cond_between.go
- cond_compare.go
- cond_eq.go
- cond_expr.go
- cond_if.go
- cond_in.go
- cond_like.go
- cond_neq.go
- cond_not.go
- cond_notin.go
- cond_null.go
- cond_or.go
- error.go
- sql.go
- writer.go
Click to show internal directories.
Click to hide internal directories.