Check this result generated by content_handler_field_multiple.inc when you have a multiple nodereference field with:

Group multiple values: yes
Show value(s) 2 starting from 0, NOT Reversed (start from last values)

You expect those two values, starting from first, then second, right? Now check the result. Starting from second, then first!

mysql> SELECT vid AS _vid, delta as _delta, nid AS _nid, field_programs_nid AS nid FROM content_field_programs WHERE vid IN (1216) ORDER BY nid ASC delta ASC;
+------+--------+------+------+
| _vid | _delta | _nid | nid  |
+------+--------+------+------+
| 1216 |      0 | 1216 | 4896 | 
| 1216 |      1 | 1216 | 4848 | 
+------+--------+------+------+
2 rows in set (0.00 sec)

I don't really understand the need for "ORDER BY nid ASC" there, the code below doesn't give me any reason it's required. The only thing happening is:

      $this->field_values[$vid][$delta] = $item;

Attaching a patch, removing that ORDER.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Status: Needs review » Postponed (maintainer needs more info)

Sorry, I don't get what is wrong in the example you provide.
+ what would be the buggy effect this causes on dislayed views ?

meba’s picture

Let's say you have nodereference field with two values:

Node1 title - which means delta of this value is 0
Node2 title - delta is 1

Because you have said that you want 2 values starting from one, in NORMAL order (not reversed), you expect to receive the titles in following order:

Node 1 title
Node 2 title

Now according to the SQL result, you have received:
Node 2 title (delta 1)
Node 1 title (delta 0)

The nodes are in wrong order. That's the problem.

Please note that this doesn't happen for non-nodereference fields

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.03 KB

I think the problem is that the alias for the nodereference field is "nid", and then the SQL engine is using that alias to resolve the ORDER BY expression.

Since the field alias can be used for ORDER BY expressions in MySQL and PostgreSQL, then the fix could be just use "_nid" and "_delta" for the first two columns in the ORDER BY clause.

markus_petrux’s picture

Status: Needs review » Fixed

Committed the patch in #3 to CVS (CCK2 and CCK3).

Status: Fixed » Closed (fixed)

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