Event Broken Concept

This commit is contained in:
Hein
2025-12-12 09:23:54 +02:00
parent 7ef1d6424a
commit 31ad217818
25 changed files with 4074 additions and 3 deletions

View File

@@ -196,6 +196,10 @@ func (b *BunAdapter) RunInTransaction(ctx context.Context, fn func(common.Databa
})
}
func (b *BunAdapter) GetUnderlyingDB() interface{} {
return b.db
}
// BunSelectQuery implements SelectQuery for Bun
type BunSelectQuery struct {
query *bun.SelectQuery
@@ -1208,3 +1212,7 @@ func (b *BunTxAdapter) RollbackTx(ctx context.Context) error {
func (b *BunTxAdapter) RunInTransaction(ctx context.Context, fn func(common.Database) error) error {
return fn(b) // Already in transaction
}
func (b *BunTxAdapter) GetUnderlyingDB() interface{} {
return b.tx
}

View File

@@ -102,6 +102,10 @@ func (g *GormAdapter) RunInTransaction(ctx context.Context, fn func(common.Datab
})
}
func (g *GormAdapter) GetUnderlyingDB() interface{} {
return g.db
}
// GormSelectQuery implements SelectQuery for GORM
type GormSelectQuery struct {
db *gorm.DB

View File

@@ -137,6 +137,10 @@ func (p *PgSQLAdapter) RunInTransaction(ctx context.Context, fn func(common.Data
return fn(adapter)
}
func (p *PgSQLAdapter) GetUnderlyingDB() interface{} {
return p.db
}
// preloadConfig represents a relationship to be preloaded
type preloadConfig struct {
relation string
@@ -897,6 +901,10 @@ func (p *PgSQLTxAdapter) RunInTransaction(ctx context.Context, fn func(common.Da
return fn(p)
}
func (p *PgSQLTxAdapter) GetUnderlyingDB() interface{} {
return p.tx
}
// applyJoinPreloads adds JOINs for relationships that should use JOIN strategy
func (p *PgSQLSelectQuery) applyJoinPreloads() {
for _, preload := range p.preloads {

View File

@@ -24,6 +24,12 @@ type Database interface {
CommitTx(ctx context.Context) error
RollbackTx(ctx context.Context) error
RunInTransaction(ctx context.Context, fn func(Database) error) error
// GetUnderlyingDB returns the underlying database connection
// For GORM, this returns *gorm.DB
// For Bun, this returns *bun.DB
// This is useful for provider-specific features like PostgreSQL NOTIFY/LISTEN
GetUnderlyingDB() interface{}
}
// SelectQuery interface for building SELECT queries (compatible with both GORM and Bun)