Skip to content

Commit

Permalink
fix sql delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tss182 committed Jul 22, 2020
1 parent 5586209 commit ff3c21b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Database struct {
where []map[string]string
whereResult string
join string
tableDelete string
groupBy string
having string
orderBy []string
Expand Down Expand Up @@ -548,6 +549,10 @@ func UpdateProses(sql *Database, value []interface{}) error {
stmt.Close()
return nil
}
func (sql *Database) TableDelete(table string) *Database {
sql.tableDelete = table
return sql
}

func (sql *Database) Delete() error {
var err error
Expand All @@ -566,7 +571,7 @@ func (sql *Database) Delete() error {
if sql.join != "" {
join = " \n" + sql.join
}
querySql := "DELETE FROM " + sql.from + join + " "
querySql := "DELETE " + sql.tableDelete + " FROM " + sql.from + join + " "
sql.query = querySql
if sql.whereResult != "" {
sql.query += "\nWHERE " + sql.whereResult
Expand Down

0 comments on commit ff3c21b

Please sign in to comment.