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
For discussion:
I am using DBViews where one view selects data from another view. In my use-case I do it because we have complex JSONB data in a (PostgreSQL) field that I am selecting and deconstructing to tabular data, which i then select from in multiple other views.
In the DependentView i am then using f"SELECT ... FROM {MainView._meta.db_table}". This creates a problem when i want to change MainView later on since that view cant be dropped because DependentView depends on it. With a DROP CASCADE this could be solved, but then the DependentView would be gone.
One workaround for now is to manually modify the migrations by adding operations to first empty and then recreate the DependentView (in both directions)
What would be nicer though is if there would be a way to specify
class DependentView(DBView):
depends_on=[MainView]
which would then make sure that if MainView changes, DependentView is first dropped, and then recreated after MainView is changed.
Does this sound like an interesting feature? If it does, I would be willing to put in time to contribute the code.
The text was updated successfully, but these errors were encountered:
@dolfandringa
Hello, Thank you for the idea, it sounds good. I am happy to welcome new contributors!
I will try to illustrate what need to be done, to be sure that we understand each other.
If view B(dependent one) depends on view A:
If view A definition changes, make migration with operations that drops views in order: view B, view A, then recreate in order: view A, view B. (created migration has 4 operations)
Optional feature: add optional parameter to refresh method, if we refresh view A, refresh all dependent views (B).
Is it what we want here? If so, then feel free to start work, I am here to help you and review it.
To discuss:
What if view depends on regular table? I am fine with limiting that relation (dependency) to views only. But it would be a nice thing to consider here. It feels natural, that a view model can depend on both things.
For discussion:
I am using DBViews where one view selects data from another view. In my use-case I do it because we have complex JSONB data in a (PostgreSQL) field that I am selecting and deconstructing to tabular data, which i then select from in multiple other views.
In the
DependentView
i am then usingf"SELECT ... FROM {MainView._meta.db_table}"
. This creates a problem when i want to changeMainView
later on since that view cant be dropped becauseDependentView
depends on it. With aDROP CASCADE
this could be solved, but then theDependentView
would be gone.One workaround for now is to manually modify the migrations by adding operations to first empty and then recreate the
DependentView
(in both directions)What would be nicer though is if there would be a way to specify
which would then make sure that if
MainView
changes,DependentView
is first dropped, and then recreated afterMainView
is changed.Does this sound like an interesting feature? If it does, I would be willing to put in time to contribute the code.
The text was updated successfully, but these errors were encountered: