otter-space-sdk/internal/postgres/custom.go
SoXX d364078acc
All checks were successful
Gitea Build Check / Build (push) Successful in 2m27s
Gitea Build Check / Build (pull_request) Successful in 2m32s
fix: wrong execution
fixed fucntion to use Exec insted of Raw.
2024-07-27 19:49:39 +02:00

26 lines
463 B
Go

package postgres
import (
"context"
"database/sql"
"errors"
"gorm.io/gorm"
)
func ExecuteRawStatement(ctx context.Context, db *gorm.DB, query string, args ...any) (*sql.Rows, error) {
if query == "" {
return nil, errors.New("query can not be empty")
}
if args == nil {
return nil, errors.New("arguments can not be nil")
}
result, err := db.WithContext(ctx).Exec(query, args...).Rows()
if err != nil {
return nil, err
}
return result, nil
}