postgresql query errors: column "n" of relation "node" does not exist

kapcsandi - January 26, 2009 - 10:18
Project:Weight
Version:6.x-1.0-beta2
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Postgresql sends error on update of weight settings for adding and/or removing node types:
# arning: pg_query() [function.pg-query]: Query failed: ERROR: column "n" of relation "node" does not exist LINE 1: UPDATE node n SET n.sticky = 100 WHERE n.sticky = 1 AND n.ty... ^ in /usr/share/drupal6/includes/database.pgsql.inc on line 139.
# user warning: query: UPDATE node n SET n.sticky = 100 WHERE n.sticky = 1 AND n.type IN ('bio') in /usr/share/drupal6/releases/releases/20090122103546/modules/weight/weight.module on line 351.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: column "n" of relation "node" does not exist LINE 1: UPDATE node n SET n.sticky = -100 WHERE n.sticky = 0 AND n.t... ^ in /usr/share/drupal6/includes/database.pgsql.inc on line 139.
# user warning: query: UPDATE node n SET n.sticky = -100 WHERE n.sticky = 0 AND n.type IN ('bio') in /usr/share/drupal6/releases/releases/20090122103546/modules/weight/weight.module on line 353.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: column "n" of relation "node" does not exist LINE 1: UPDATE node n SET n.sticky = 1 WHERE n.sticky > 1 AND n.type... ^ in /usr/share/drupal6/includes/database.pgsql.inc on line 139.
# user warning: query: UPDATE node n SET n.sticky = 1 WHERE n.sticky > 1 AND n.type NOT IN ('articles','glossary','news') in /usr/share/drupal6/releases/releases/20090122103546/modules/weight/weight.module on line 371.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: column "n" of relation "node" does not exist LINE 1: UPDATE node n SET n.sticky = 0 WHERE n.sticky < 0 AND n.type... ^ in /usr/share/drupal6/includes/database.pgsql.inc on line 139.
# user warning: query: UPDATE node n SET n.sticky = 0 WHERE n.sticky < 0 AND n.type NOT IN ('articles','glossary','news') in /usr/share/drupal6/releases/releases/20090122103546/modules/weight/weight.module on line 373.

This patch needs review and test on mysql database:

--- weight/weight.module        2009-01-26 01:28:54.000000000 +0100
+++ weight_new/weight.module    2009-01-26 10:38:28.000000000 +0100
@@ -348,9 +348,9 @@
   }
   if ($weight_node_types) {
     $placeholders = db_placeholders($weight_node_types, 'text');
-    db_query("UPDATE {node} n SET n.sticky = 100 WHERE n.sticky = 1 AND n.type IN ($placeholders)", $weight_node_types);
+    db_query("UPDATE {node} SET sticky = 100 WHERE sticky = 1 AND type IN ($placeholders)", $weight_node_types);
     $count = db_affected_rows();
-    db_query("UPDATE {node} n SET n.sticky = -100 WHERE n.sticky = 0 AND n.type IN ($placeholders)", $weight_node_types);
+    db_query("UPDATE {node} SET sticky = -100 WHERE sticky = 0 AND type IN ($placeholders)", $weight_node_types);
     $count += db_affected_rows();
     drupal_set_message(t('@count nodes weight enabled.', array('@count' => $count)));
   }
@@ -368,15 +368,15 @@
   }
   if ($weight_node_types) {
     $placeholders = db_placeholders($weight_node_types, 'text');
-    db_query("UPDATE {node} n SET n.sticky = 1 WHERE n.sticky > 1 AND n.type NOT IN ($placeholders)", $weight_node_types);
+    db_query("UPDATE {node} SET sticky = 1 WHERE sticky > 1 AND type NOT IN ($placeholders)", $weight_node_types);
     $count = db_affected_rows();
-    db_query("UPDATE {node} n SET n.sticky = 0 WHERE n.sticky < 0 AND n.type NOT IN ($placeholders)", $weight_node_types);
+    db_query("UPDATE {node} SET sticky = 0 WHERE sticky < 0 AND type NOT IN ($placeholders)", $weight_node_types);
     $count += db_affected_rows();
   }
   else {
-    db_query("UPDATE {node} n SET n.sticky = 1 WHERE n.sticky > 1");
+    db_query("UPDATE {node} SET sticky = 1 WHERE sticky > 1");
     $count = db_affected_rows();
-    db_query("UPDATE {node} n SET n.sticky = 0 WHERE n.sticky < 0");
+    db_query("UPDATE {node} SET sticky = 0 WHERE sticky < 0");
     $count += db_affected_rows();
   }
   drupal_set_message(t('@count nodes weight disabled.', array('@count' => $count)));

It only eliminates the ALIAS-es from UPDATE rows.

#1

NancyDru - January 26, 2009 - 16:20

I just looked at the PostgresQl manual and it says they are allowed.

#2

NancyDru - January 26, 2009 - 17:11
Status:needs review» fixed

I removed the aliases and a little bit of other clean up.

#3

System Message - February 9, 2009 - 17:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.