metabase / toucan

A classy high-level Clojure library for defining application models and retrieving them from a DB
Eclipse Public License 1.0
569 stars 49 forks source link

Hydration Functions are Too Eager #24

Closed axrs closed 6 years ago

axrs commented 6 years ago

I've come across a situation with lazy model loading not updating simple hydration functions.

In the main execution path, we can select a single company, then invoke hydrate for users. The users model will be lazily loaded and hydrated. Awesome.

During the loading of users, a new ^:hydration function is loaded for the permissions. Unfortunately, the simple hydration method has already realized the delay; and thus doesn't know of the new permissions hydration function.

The fix I've come across is to put hydrations into a seperate file and ensure it's required by what needs it. This however feels counter intuitive when models can be resolved when required.

Thoughts?

axrs commented 6 years ago

When a model is resolved (in toucan.db/resolve-model-from-symbol), the delays could be converted to an atom and reset! or at least set! back to a delay

axrs commented 6 years ago

27