Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pkg/server/datastore/sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,33 @@ func New(log logrus.FieldLogger) *Plugin {
}
}

// RawScan runs a raw query and scans a single result into dest.
// Test-support escape hatch for the shared sqltest suite.
func (ds *Plugin) RawScan(dest any, query string) error {
return ds.db.Raw(query).Scan(dest).Error
}

// RawExec runs a raw statement against the underlying *sql.DB.
// Test-support escape hatch for the shared sqltest suite.
func (ds *Plugin) RawExec(query string, args ...any) error {
_, err := ds.db.raw.Exec(query, args...)
return err
}
Comment thread
MarcosDY marked this conversation as resolved.

// DatabaseType returns the configured database type (e.g. "sqlite3",
// "postgres", "mysql").
// Test-support escape hatch for the shared sqltest suite.
func (ds *Plugin) DatabaseType() string {
return ds.db.databaseType
}

// Rebind rewrites "?" placeholders to the configured dialect's positional
// placeholder form using the same logic production queries use.
// Test-support escape hatch for the shared sqltest suite.
func (ds *Plugin) Rebind(query string) string {
return maybeRebind(ds.db.databaseType, query)
}
Comment thread
MarcosDY marked this conversation as resolved.

// CreateBundle stores the given bundle
func (ds *Plugin) CreateBundle(ctx context.Context, b *common.Bundle) (bundle *common.Bundle, err error) {
if err = ds.withWriteTx(ctx, func(tx *gorm.DB) (err error) {
Expand Down
Loading
Loading