Skip to content
Snippets Groups Projects
Commit 547b573df49e authored by Christophe de Vienne's avatar Christophe de Vienne
Browse files

SQLHelper: add 'raw' versions of the main functions

parent fa4e7de85792
No related branches found
No related tags found
No related merge requests found
Pipeline #15644 passed
......@@ -26,6 +26,11 @@
return GetContext(h.ctx, h.sqle, obj, query, &h.log)
}
func (h *SQLHelper) GetRaw(obj interface{}, sql string, args ...interface{}) error {
SQLTrace(&h.log, sql, args)
return h.sqle.GetContext(h.ctx, obj, sql, args...)
}
// GetByPKey loads a mapped structure
func (h *SQLHelper) GetByPKey(obj Mapped, value interface{}) error {
return h.GetBy(obj, obj.PKeyColumn(), value)
......@@ -51,8 +56,13 @@
return SelectContext(h.ctx, h.sqle, obj, query, &h.log)
}
func (h *SQLHelper) SelectRaw(obj interface{}, sql string, args ...interface{}) error {
SQLTrace(&h.log, sql, args)
return h.sqle.SelectContext(h.ctx, obj, sql, args...)
}
// Exec executes a query
func (h *SQLHelper) Exec(query sq.Sqlizer) (sql.Result, error) {
return ExecContext(h.ctx, h.sqle, query, &h.log)
}
......@@ -54,10 +64,15 @@
// Exec executes a query
func (h *SQLHelper) Exec(query sq.Sqlizer) (sql.Result, error) {
return ExecContext(h.ctx, h.sqle, query, &h.log)
}
func (h *SQLHelper) ExecRaw(sql string, args ...interface{}) (sql.Result, error) {
SQLTrace(&h.log, sql, args)
return h.sqle.ExecContext(h.ctx, sql, args...)
}
// Query executes a query
func (h *SQLHelper) Query(query sq.Sqlizer) (*sqlx.Rows, error) {
return QueryContext(h.ctx, h.sqle, query, &h.log)
}
......@@ -59,8 +74,14 @@
// Query executes a query
func (h *SQLHelper) Query(query sq.Sqlizer) (*sqlx.Rows, error) {
return QueryContext(h.ctx, h.sqle, query, &h.log)
}
// QueryRaw executes a raw SQL query
func (h *SQLHelper) QueryRaw(sql string, args ...interface{}) (*sqlx.Rows, error) {
SQLTrace(&h.log, sql, args)
return h.sqle.QueryxContext(h.ctx, sql, args...)
}
// Insert inserts a Mapped into the db
func (h *SQLHelper) Insert(instances ...Mapped) (sql.Result, error) {
query := SQLInsert(instances...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment