fix(lagoon): warn on after-commit work registered after lagoon:after_commit; correct the OnDatabase example and pivot read guidance (quick-261028-r16)
- flushStatementAfterCommit marks the statement; AfterCommit logs a warning when work is buffered on a flushed statement that no longer holds GORM's transaction. Log-only: the work still never runs, the write succeeds - subtests pin the late callback warning, a callback between commit and flush, and a reused chained statement staying silent - README OnDatabase example registers After(gorm:create).Before(commit), matching docs/database/transactions.md - RegisterJoinTable: pivot-ordered reads join the pivot table explicitly; a Preload cannot be ordered by a pivot column
This commit is contained in:
@@ -84,7 +84,7 @@ return lagoon.OnDatabase(app, func(_ *sql.DB, gdb *gorm.DB) error {
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Register such a callback with a `Before("gorm:commit_or_rollback_transaction")` constraint, as above. lagoon runs a single-statement write's after-commit work from its own callback right after that commit step; a callback that GORM sorts after it buffers work that is never run, without an error.
|
||||
> Register such a callback with a `Before("gorm:commit_or_rollback_transaction")` constraint, as above. lagoon runs a single-statement write's after-commit work from its own callback right after that commit step; a callback that GORM sorts after it buffers work that is never run. The write still succeeds, and lagoon logs a warning when that happens.
|
||||
|
||||
## Boot-time work that needs the database
|
||||
|
||||
|
||||
Reference in New Issue
Block a user