Skip to content

Commit

Permalink
added a genericExec function and renamed buildSQL to buildSelectSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Jul 27, 2016
1 parent aba0597 commit d782669
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ func genericUpdate(store Store, model *Model, cols Columns) error {
Log(stmt)
}
_, err := store.NamedExec(stmt, model.Value)
if err != nil {
Log(fmt.Sprintf("Error: Update: %q", err))
}
return err
}

func genericDestroy(store Store, model *Model) error {
stmt := fmt.Sprintf("DELETE FROM %s WHERE id = %d", model.TableName(), model.ID())
return genericExec(store, stmt)
}

func genericExec(store Store, stmt string) error {
if Debug {
Log(stmt)
}
Expand Down
4 changes: 2 additions & 2 deletions sql_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (sq *SQLBuilder) compile() {
if sq.Query.RawSQL.Fragment != "" {
sq.sql = sq.Query.RawSQL.Fragment
} else {
sq.sql = sq.buildSQL()
sq.sql = sq.buildSelectSQL()
}
sq.sql = sq.Query.Connection.Dialect.TranslateSQL(sq.sql)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (sq *SQLBuilder) log() {
}
}

func (sq *SQLBuilder) buildSQL() string {
func (sq *SQLBuilder) buildSelectSQL() string {
cols := sq.buildColumns()

fc := sq.buildfromClauses()
Expand Down

0 comments on commit d782669

Please sign in to comment.