How to remove and add joins to a view? Because of some buggy handlers I need to write a hook that will:


Get location_instance table's alias from the original query
Remove location_instance table join
Remove that alias join
Remove a location table join
Add 2 new joins


Apparently views does things a little differently so I can't just $query-&gt;join() my way to freedom. How exactly do I accomplish the above?
This is an issue I have been sturggling with myself.  You may want to start by looking at hook_views_query_alter() and read this related Drupal Answers question.

Then you can use these functions: views_plugin_query_default to actually affect change on your query.