You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three field types for deriving values on SQLAlchemy models. All are defined inline on the model and delegate their logic to functions in `post_calculations.py`.
64
+
65
+
#### `computed_field`
66
+
Pure Python. No session required. Cached permanently on the instance — survives `expire()` and `commit()`.
67
+
68
+
Use when the value is derivable from already-loaded columns only (arithmetic, date calculations, string formatting).
69
+
70
+
#### `session_computed_field`
71
+
Session-aware. Cache is cleared on `expire()` and `commit()` so DB-derived values are never stale.
72
+
73
+
Use when the calculation requires a DB query — joins, lookups against reference tables, aggregates over related rows.
74
+
75
+
#### `computed_hybrid`
76
+
Wraps `hybrid_property`. Not cached — recalculates on every access. The only type usable in queries (`WHERE`, `ORDER BY`, `filter()`).
77
+
78
+
Use when you need the value available at the query level, not just on loaded instances.
0 commit comments