[development] db_rewrite_sql

Jose A. Reyero drupal at reyero.net
Thu Apr 19 21:23:51 UTC 2007

Moshe Weitzman wrote:
>> I know I have participated in a discussion like this before, but
>> couldn't find the issue. So here it is again: What about passing a
>> unique identifier along with every call of db_rewrite_sql? Instead of
>> just wrapping db_rewrite_sql() we could also pass $module and $key so
>> we have accurate namespaces for each query. (Or, we could just do it
>> like hook_mail_alter(), but I think there could be namespace
>> conflicts if a module named foo_module's foo_module_key screws with a
>> module named foo's foo_module_key :P)
The thing is that it's not about uniquely identifying queries, but about
rewriting some kind of queries whatever module they come from. I.e. some
modules would want to rewrite *all* node listing queries.
So what we really need there is just some more information about
'function' and some 'context' but not really an identifier like in the
case of $form_id. I'm talking abt passing parameters like
'node_listing', 'vocabulary_loading' or 'administration', 'content',
'view', etc...
> this was proposed in the original db_rewrite_sql() but didn't get in.
> We called them query hints or somesuch ... We had enough to chew on at
> that time. It is time to try again, as you propose.
Yes, It's about time we improve it a little bit. That function got the
job done at that time and I think so far it's proven to be quite useful
for modules - og, i18n :-)
But really we could add some more information there so we don't have to
relay anymore on preg_match or path for guessing about the kind of query
it is.

More information about the development mailing list