Add support for DELETE statements.
This commit is contained in:
parent
70d6f84375
commit
bc6a2bbcac
14 changed files with 492 additions and 543 deletions
|
|
@ -1,6 +1,11 @@
|
|||
package sqlbuilder
|
||||
|
||||
import "bytes"
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"github.com/sub0zero/go-sqlbuilder/sqlbuilder/execution"
|
||||
"github.com/sub0zero/go-sqlbuilder/types"
|
||||
)
|
||||
|
||||
func serializeExpressionList(expressions []Expression, buf *bytes.Buffer) error {
|
||||
for i, value := range expressions {
|
||||
|
|
@ -33,3 +38,25 @@ func serializeProjectionList(projections []Projection, buf *bytes.Buffer) error
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Query(statement Statement, db types.Db, destination interface{}) error {
|
||||
query, err := statement.String()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return execution.Execute(db, query, destination)
|
||||
}
|
||||
|
||||
func Execute(statement Statement, db types.Db) (res sql.Result, err error) {
|
||||
query, err := statement.String()
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res, err = db.Exec(query)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue