Because RAND() isn't in the select list. Attached patch fixes.

CommentFileSizeAuthor
#4 image_222977.patch1.35 KBdrewish
image.patch1.01 KBUberLord

Comments

drewish’s picture

Title: [PATCH] image.module fails with postgresql with random images » image.module fails with postgresql with random images
Status: Active » Needs review
HorsePunchKid’s picture

Status: Needs review » Reviewed & tested by the community

The patch does fix the error in Postgres. But I think this just reintroduces the possibility of having duplicates, since one could (and almost certainly would) have the same node ID but a distinct random number. In other words, it's pretty much the same as not having the DISTINCT there in the first place. Unless I don't understand how that keyword works--but I'm pretty sure it applies to the entire SELECT list.

I don't know of any good solution for Postgres. However, the error is pretty bad, and an unlikely duplicate is better than a guaranteed error. We could fork the queries into MySQL and Postgres versions, I suppose.

drewish’s picture

that's kind of a mixed review... should this really be committed as it is?

drewish’s picture

Version: 5.x-1.7 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.35 KB

couldn't it be DISTINCT(n.nid), RAND() ? that would make sure the nid is distinct...

HorsePunchKid’s picture

#4 seems to work fine in Postgres. Not sure why that didn't occur to me. :)

drewish’s picture

Status: Needs review » Fixed

great, committed to DRUPAL-5, DRUPAL-5--2, and HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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