Greetings,

I found that you don't have Postgre support in your module.
I would like to provide you the following patch for hook_install. I did the following:
1. PostgreSQL support
2. More accurate types used for MySQL script (in accordance with types used in core tables)

function favorite_nodes_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $result = db_query("CREATE TABLE favorite_nodes (
          nid     int(10) unsigned NOT NULL,
          uid     int(10) unsigned NOT NULL,
          last    int(11) NOT NULL,
          PRIMARY KEY (nid, uid)
          ) Type=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
        ");
      break;
    case 'pgsql':
      $result = db_query("CREATE TABLE favorite_nodes (
          nid     integer NOT NULL,
          uid     integer NOT NULL,
          last    integer NOT NULL,
          PRIMARY KEY (nid, uid)
          );
        ");
      break;
  }
  
  if ($result) {
    drupal_set_message(t("favourite_nodes module database tables created successfully."));  
  } else {
    drupal_set_message(t("favourite_nodes module database table creation failure. Please view the favourite_nodes module folder and read the README.txt"), 'error');    
  }
}

Thank you.

Comments

zig007’s picture

StatusFileSize
new3.89 KB

Hi,
I used this install script instead of the original, and it worked perfectly.
However, it made another bug in the module surface. In one(or was it two?) place(s), this SQL is used:
"SELECT COUNT(*) FROM node n INNER JOIN favorite_nodes f ON n.nid = f.nid WHERE n.type = 'resource' AND f.uid = 1 ORDER by f.last DESC"

I am not sure if its allowed to do this in MySQL, but in PgSQL (and all other SQL server variants i have worked with) it is not allowed to use "ORDER BY" within a single count like that(since it has no point whatsoever).

I just tried removing the "ORDER BY"part, but for some reason Drupal has not yet understood this. I'll be back when it does.

Attached a file with my SQL changes in it. Haven't tried, but it should work in MySQL aswell.

Oh, and this was with regards to the 5.x version.

jaydub’s picture

Title: PostgreSQL support, install improved » PostgreSQL support
Version: 4.7.x-1.x-dev » 6.x-1.x-dev
Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new1.73 KB
new1.76 KB
new767 bytes

Following up on this issue, I've provided patches for the 5.x
version of favorite_nodes.install and both 5.x and 6.x versions
of favorite_nodes.modules to enable fully functional PostgreSQL
support.

The changes to favorite_nodes.module fix the issue mentioned
in #2 of this issue regarding the ORDER BY clause and problems
with the COUNT queries generated by pager_query. Adding an explicit
count query to be used in the pager_query call solves the problem.

kbahey’s picture

Status: Needs review » Fixed

Thanks.

Committed to 5.x-1.x-dev, and 6.x-1.x-dev.

P.S. Patches that span files should be in one patch file. So, for the above, the 5.x patch for the .module and .install should be one patch.

See http://drupal.org/patch for more details.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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