This is a followup to http://drupal.org/node/621142

DISTINCT is not a valid option for many query types. It is really very much part of the query settings, so we should move it.

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new5.73 KB

Here is a patch.

It convertes the distinct option, if set. I tested the patch quite intensive.

What about groupby? I don't know any contrib/custom backend which supports the option at the moment.

bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Applies, seems to work (did a quick test).

I agree that groupby should be handled the same (move it to query options), it's an sql thing, so it makes sense.
Doesn't need to happen in this issue though.

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to D6. Didn't apply to D7.

becw’s picture

StatusFileSize
new6.07 KB

The patch applies to 7.x-3.x with fuzz; I re-rolled it and am attaching a version that applies cleanly. It moves the setting, but using 'distinct' still yields an error, since evidently new work is needed to support distinct queries on D7:

Exception: d7cx: Column-level distinct is not supported yet. in views_plugin_query_default->compile_fields() (line 940 of /shared/vash/sandboxes/white/barnard/site/www/sites/all/modules/views/plugins/views_plugin_query_default.inc).

dawehner’s picture

See #863478: Distinct is not supported by dbtng

It still seems not to be supported? I'm confused a bit, and asked berdir.

dawehner’s picture

Status: Patch (to be ported) » Fixed

Commited the patch with a commented out distinct option. Let's fix this later.

rszrama’s picture

Status: Fixed » Needs work

I'm not sure, but I think the commented out distinct option is why I'm getting undefined index errors on every View for this bit o' code:

    // Make the query distinct if the option was set.
    if ($this->options['distinct']) {
      // $this->set_distinct();
    }

Perhaps the if statement should have been commented out, too?

(Sorry, I don't know enough about how Views uses issue tags to tell if the alpha-4 blocker status is for 2.x or 3.x issues, so I'm leaving it alone for now.)

dawehner’s picture

I think here should be used !empty

rszrama’s picture

Status: Needs work » Needs review
StatusFileSize
new1.21 KB

Alrighty, added an empty().

dawehner’s picture

Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

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