berlindb / core

All of the required core code
MIT License
252 stars 27 forks source link

Issue/61 - Refactor prepare_query to be extend-able directly by queries #62

Closed alexstandiford closed 4 years ago

alexstandiford commented 4 years ago

I brought this up in issue #61

The intent here is to make it possible for child classes to extend prepare_query without utilizing WordPress hooks. The key benefit of this is better-control over this hook, and to make it easier for direct integrations to extend the Query class. Without this, the only way to extend Query is through hooks, which in the context of a child class is awkward.

To better-articulate the goal, this makes it possible for a child class to directly view the query arguments, and manipulate the actual query that comes through. This is a little different than a query processor in-that it isn't a BerlinDB-wide integration, but instead a query-specific integration.

Say, for example, you want to fetch data by querying a pivot table. This would make it possible to add query args for this specific type of query that can tell it to JOIN the other tables in the pivot table with minimal changes to how the system works elsewhere.

alexstandiford commented 4 years ago

This doesn't really work in BerlinDB, at least not now due to the nature of how shape_items works. You can't really do joins or something more sophisticated unless there is some way to actually tell BerlinDB to just run the query.