Skip to content

Commit

Permalink
Merge pull request #14 from joelmdesouza/master
Browse files Browse the repository at this point in the history
Adjusted UpdateTable for compatibility with other Adapters
  • Loading branch information
crgimenes committed Feb 14, 2018
2 parents ad78673 + a0b6be8 commit 721f801
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tables.go
Expand Up @@ -278,29 +278,29 @@ func UpdateTable(w http.ResponseWriter, r *http.Request) {

config.PrestConf.Adapter.SetDatabase(database)

where, whereValues, err := config.PrestConf.Adapter.WhereByRequest(r, 1)
setSyntax, values, err := config.PrestConf.Adapter.SetByRequest(r, 1)
if err != nil {
err = fmt.Errorf("could not perform WhereByRequest: %v", err)
err = fmt.Errorf("could not perform UPDATE: %v", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
sql := config.PrestConf.Adapter.UpdateSQL(database, schema, table, setSyntax)

pid := len(whereValues) + 1 // placeholder id
pid := len(values) + 1 // placeholder id

setSyntax, values, err := config.PrestConf.Adapter.SetByRequest(r, pid)
where, whereValues, err := config.PrestConf.Adapter.WhereByRequest(r, pid)
if err != nil {
err = fmt.Errorf("could not perform UPDATE: %v", err)
err = fmt.Errorf("could not perform WhereByRequest: %v", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
sql := config.PrestConf.Adapter.UpdateSQL(database, schema, table, setSyntax)

if where != "" {
sql = fmt.Sprint(
sql,
" WHERE ",
where)
values = append(whereValues, values...)
values = append(values, whereValues...)
}

sc := config.PrestConf.Adapter.Update(sql, values...)
Expand Down

0 comments on commit 721f801

Please sign in to comment.