On Monday 21 August 2006 23:15, Scott McLewin wrote:
I've run into a condition where my nodes with locative data filter exactly as I want them to based on location, but nodes without locative data don't show up (I know why - it is because I INNER JOINED them with the location table, which yields no result).
Have you tried the following? $return['where'] = "a.longitude IS NULL OR your_where_clause_here"; If that doesn't work... If you can enforce that a certain node types always have location data, your where clause could like like $return['where'] = "$primary_table.type IN (list_of_node_types) OR your_where_clause"; You could try a nested query, but this may have problems with efficiency and portability $return['where'] = "$primary_table.nid NOT IN (SELECT oid FROM {location}) OR your_where_clause"; And you could write a hook_nodeapi that inserts a row in location for every node, inserting NULL for values. Then use the first query above. This may have a problem for nodes inserted before your module was installed, however.
If this thread has become inappropriate for the overall developers list, I've placed a copy of it on http://mclewin.com/node/495. My hook_db_rewrite_sql implementation is posted there as well.
I'm writing here in case someone has a better idea. Finally, I recommend you don't alias {location} to 'a'. It's really not a descriptive abbreviation, and likely to cause conflicts with some other hook_db_rewrite_sql eventually. Why not use 'location' and never have to worry about that? -Dave