Closed (fixed)
Project:
Case Tracker
Version:
5.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Aug 2007 at 15:11 UTC
Updated:
7 Dec 2007 at 12:14 UTC
Jump to comment: Most recent file
Comments
Comment #1
jax commentedWhen I change the db_query_range(db_rewrite_sql()) to a normal db_query() it works like it should.
Comment #2
jax commentedThe original query is:
This is altered by db_rewrite_sql() to:
This second query gives the dupes. So the problem might be with the hook_db_rewrite_sql() in og.module or something. I'll try to look into this later.
Comment #3
jax commentedOG inserts the following in node_access when creating a node:
Then node_db_rewrite_sql() inserts a join from node on node_access resulting in dubbel rows. I'm not sure how to resolve this though.
Comment #4
jax commentedChanging project. Didn't read the warning the first time.
Comment #5
jax commentedAnd fixed the typo in the title.
Comment #6
jax commentedIt's og_node_grants() that feeds the where's to the db_rewrite_sql(). What the query tries to achieve is determining if the user has access to that node. But when your access rights match several rows in node_access your original query will start to return incorrect results because of the join. The only way to write the query in a semantically correct way is to use a subquery.
So the correct query that should come out of db_rewrite_sql is:
There is the concern that not all versions of MySQL support subqueries. Don't know about the other platforms though.
Comment #7
jax commentedDrupal uses DISTINCT to fix the multiple rows issue with node_access. But the db_distinct_field() functions expects the exact field that is passed to db_rewrite_sql() to be present in the SELECT clause. This is not the case with the query in the casetracker module. So in stead of tampering with core and changing everything I've attached a patch that just adds that field to the query so that the DISTINCT is inserted correctly in the query.
After adding n.nid to the select clause the query that is returned by db_rewrite_sql() is:
Comment #8
zero2one commentedIs in the dev release.
Will be in the next official release
Comment #9
zero2one commentedIs fixed in the casetracker 5.x-1.3-beta1 release.
Comment #10
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.