Commit 8ed4d80
fix: use subquery loading for Books relationships to prevent DetachedInstanceError (#1279)
All relationship attributes on the Books model (series, comments, languages,
authors, tags, data, ratings, publishers, identifiers) used the default lazy
loading strategy. This causes sqlalchemy.orm.exc.DetachedInstanceError when
Jinja2 templates access these attributes after the SQLAlchemy session has been
closed, resulting in intermittent 500 errors.
Switching to lazy='subquery' ensures all relationship data is loaded eagerly
alongside the main query, preventing any lazy-load attempts on detached
instances.
Fixes #1067, #1130, #1139
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 33bbf34 commit 8ed4d80
1 file changed
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| |||
0 commit comments