testing your module and having some trouble getting it working. getting error messages about SQL syntax and have no real clue what´s causing this. using a shared host and wonder if my host may lack proper support.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(n.nid), nr.field_subnodes_tax_value AS tid FROM node n ' at line 1 query: SELECT n.vid, DISTINCT(n.nid), nr.field_subnodes_tax_value AS tid FROM node n INNER JOIN content_type_child nr ON nr.vid = n.vid AND nr.nid = n.nid WHERE nr.field_subnodes_ref_nid = 265 in "PATH"/sites/all/modules/subnodes_by_taxonomy/subnodes_by_taxonomy.module on line 385.

getting similar message when testing creating content for a parent node as well as a child node.

any clue on what´s causing this?

thank you for sharing your work, hope you benefit from people joining into some testing.

BR/jesse

Comments

vm’s picture

version of MySQL in use?

markus_petrux’s picture

Title: SQL error » SQL error / DISTINCT(n.nid) added to certain queries when node access module is enabled
Status: Active » Needs review

Actually, I think this is caused by a node access module. Probably, we do not have to use db_rewrite_sql() here.

Could you please try the following changes to subnodes_by_taxonomy.module?

-      $sql = db_rewrite_sql('SELECT n.vid, n.nid, '. $content_taxonomy_column .' AS tid
+      $sql = 'SELECT n.vid, n.nid, '. $content_taxonomy_column .' AS tid
         FROM {node} n
           INNER JOIN {'. $nodereference_table .'} nr ON nr.vid = n.vid AND nr.nid = n.nid
           '. $content_taxonomy_join .'
-        WHERE nr.'. $nodereference_column .' = %d', 'n', 'vid');
+        WHERE nr.'. $nodereference_column .' = %d';
-      $sql = db_rewrite_sql('SELECT nr.'. $nodereference_column .' AS nid, '. $content_taxonomy_column .' AS tid
+      $sql = 'SELECT nr.'. $nodereference_column .' AS nid, '. $content_taxonomy_column .' AS tid
         FROM {node} n
           INNER JOIN {'. $nodereference_table .'} nr ON nr.vid = n.vid AND nr.nid = n.nid
           '. $content_taxonomy_join .'
-        WHERE n.nid = %d');
+        WHERE n.nid = %d';
markus_petrux’s picture

Category: support » bug
Status: Needs review » Fixed

Well, I have committed the fix in #2 to CVS.

Re: "thank you for sharing your work, hope you benefit from people joining into some testing."

Sure, thanks for reporting this issue. Also, if it doesn't exactly fit into someone else's use-case, maybe it can be used as an example on how to play with CCK fields and relations between nodes.

Our use case is: parent nodes are Games, and child nodes are Platforms. Each game can be related to one or more platforms, and there are a lot of attributes that need to be managed at Game/Platform level, hence we use child nodes, and the platforms are taxonomies that give meaning to the relation. Game/Platform data can be edited from the tabs in the parent game node. We also had to write a module that allows us to enable/disable Game/Platform fields depending on the platform, but that one has a lot of particular customizations and it cannot be shared. The whole thing works like a charm.

hyperzmart’s picture

Category: bug » support
Status: Fixed » Active

INITIAL TEST WORKS!

out traveling, just got to a connected computer.. thank you much for swift response.

MY SYSTEM
MySQL: 5.0.81
PHP: 5.2.10
Drupal: 6.13
YES I do use Node Access: 6.x-1.1

just tried your fix #2 and got totally rid of the SQL error. SQL issue SOLVED!

do have another other issue*, will make a clean install and test better when back from worldly adventures
*) WHEN: Having a parentNode and from there created a childNode, this message appears: "Could not locate information about the new child node."

.. will get back to you once having my own equipment at hand and tested on clean installs.

again, thank you very much and sorry not being here sooner.

/jesse

markus_petrux’s picture

Category: support » bug
Status: Active » Fixed

Please, open a separate support request.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.