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 'INNER JOIN node n ON c.nid = n.nid WHERE n.type = 'story'' at line 1 query: DELETE FROM content_complete c INNER JOIN node n ON c.nid = n.nid WHERE n.type = 'story' in /Users/pvhee/Sites/youthagora/templates/master/profiles/master/modules/contrib/content_complete/content_complete.module on line 232.

It seems the checks are not done properly in content_complete.module line 232.

CommentFileSizeAuthor
#10 596978.patch612 bytesbenoit.borrel

Comments

pvhee’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

sinasquax’s picture

Version: 6.x-1.2-beta4 » 6.x-1.2

I still have the problem, i corrected it by using this kind of query for deleting :

DELETE c FROM {content_complete} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = '%s'

(Removed USING and put the name of deleting table before the FROM statement)

sinasquax’s picture

Status: Closed (fixed) » Active
pvhee’s picture

Status: Active » Fixed

I've committed this, thanks.

Note that the correct syntax is DELETE FROM and not DELETE c FROM (see http://dev.mysql.com/doc/refman/5.0/en/delete.html)

sinasquax’s picture

I don't think that using DELETE FROM work with INNER JOIN, taken from your link :


 You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the particular condition in the WHERE clause. However, you cannot use ORDER BY or LIMIT  in a multiple-table DELETE. The table_references clause lists the tables involved in the join. Its syntax is described in Section 12.2.8.1, “JOIN  Syntax”.

For the first multiple-table syntax, only matching rows from the tables listed before the FROM clause are deleted. For the second multiple-table syntax, only matching rows from the tables listed in the FROM clause (before the USING clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching:

DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;

Or:

DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;

These statements use all three tables when searching for rows to delete, but delete matching rows only from tables t1 and t2.
pvhee’s picture

Thanks for looking into this. Could you make a tested patch for the latest dev snapshot and I'll commit?

sinasquax’s picture

Status: Fixed » Closed (fixed)

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

benoit.borrel’s picture

Version: 6.x-1.2 » 6.x-1.4
Status: Closed (fixed) » Needs review
StatusFileSize
new612 bytes

using 6.x-1.4 and encountered the bug

proper single-table SQL syntax should be:

DELETE FROM {content_complete} WHERE nid IN (SELECT n.nid FROM {node} n WHERE n.type = '%s')
pvhee’s picture

Status: Needs review » Fixed

This is committed now, thanks!

Status: Fixed » Closed (fixed)

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