func (q SqlQuery) Query(ctx context.Context, sql sq.SelectBuilder) (*sqlx.Rows, error) { sql = sql.PlaceholderFormat(sq.Dollar) query, args, err := sql.ToSql() if err != nil { return nil, errors.Wrap(err, 1) } return q.QueryRaw(ctx, query, args) }
// Get gets a single row returned by the provided sql builder into the provided dest. // dest must be a non-slice value of the correct record type. func (q SqlQuery) Get(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error { sql = sql.PlaceholderFormat(sq.Dollar) query, args, err := sql.ToSql() if err != nil { return errors.Wrap(err, 1) } return q.GetRaw(ctx, query, args, dest) }
func (q SqlQuery) Get(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error { db := sqlx.NewDb(q.DB, "postgres") sql = sql.PlaceholderFormat(sq.Dollar) query, args, err := sql.ToSql() if err != nil { return err } return db.Get(dest, query, args...) }
func (q SqlQuery) Select(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error { db := sqlx.NewDb(q.DB, "postgres") sql = sql.PlaceholderFormat(sq.Dollar) query, args, err := sql.ToSql() if err != nil { return err } log.WithField(ctx, "sql", query).Info("Executing query") return db.Select(dest, query, args...) }