Default aliasing refactoring.
This commit is contained in:
parent
22426c8cad
commit
5ad213885f
16 changed files with 198 additions and 124 deletions
|
|
@ -29,14 +29,6 @@ type updateStatementImpl struct {
|
|||
returning []Projection
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) Query(db types.Db, destination interface{}) error {
|
||||
return Query(u, db, destination)
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) Execute(db types.Db) (res sql.Result, err error) {
|
||||
return Execute(u, db)
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) SET(values ...interface{}) UpdateStatement {
|
||||
|
||||
for _, value := range values {
|
||||
|
|
@ -56,12 +48,14 @@ func (u *updateStatementImpl) WHERE(expression BoolExpression) UpdateStatement {
|
|||
}
|
||||
|
||||
func (u *updateStatementImpl) RETURNING(projections ...Projection) UpdateStatement {
|
||||
u.returning = projections
|
||||
u.returning = defaultProjectionAliasing(projections)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) Sql() (sql string, args []interface{}, err error) {
|
||||
out := &queryData{}
|
||||
out.statementType = update_statement
|
||||
|
||||
out.WriteString("UPDATE ")
|
||||
|
||||
if u.table == nil {
|
||||
|
|
@ -84,18 +78,6 @@ func (u *updateStatementImpl) Sql() (sql string, args []interface{}, err error)
|
|||
out.WriteString(" ")
|
||||
}
|
||||
|
||||
//for i, column := range u.columns {
|
||||
// if i > 0 {
|
||||
// out.WriteString(", ")
|
||||
// }
|
||||
//
|
||||
// out.WriteString(column.Name())
|
||||
//
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
//}
|
||||
|
||||
err = serializeColumnList(u.columns, out)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -132,8 +114,7 @@ func (u *updateStatementImpl) Sql() (sql string, args []interface{}, err error)
|
|||
return "", nil, errors.New("Updating without a WHERE clause.")
|
||||
}
|
||||
|
||||
out.WriteString(" WHERE ")
|
||||
if err = u.where.Serialize(out); err != nil {
|
||||
if err = out.WriteWhere(u.where); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -149,3 +130,11 @@ func (u *updateStatementImpl) Sql() (sql string, args []interface{}, err error)
|
|||
|
||||
return out.buff.String(), out.args, nil
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) Query(db types.Db, destination interface{}) error {
|
||||
return Query(u, db, destination)
|
||||
}
|
||||
|
||||
func (u *updateStatementImpl) Execute(db types.Db) (res sql.Result, err error) {
|
||||
return Execute(u, db)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue