many-many extra fields min-max-avg-sum queries issue

34 views
Skip to first unread message

Tony Air

unread,
Nov 11, 2014, 6:20:52 PM11/11/14
to silverst...@googlegroups.com
DataQuery object doesn't let us use many many extra fields values.
For an instance (DataList)->max('ProductPage_ProductItems.SortOrder') will return an error cuz quotes will be added I think it will be great if we will remove them at the DataQuery.php

Stevie Mayhew

unread,
Nov 11, 2014, 7:57:16 PM11/11/14
to silverst...@googlegroups.com
Hi Tony,

The $many_many_extraFields configuration is a per-class configuration, so you should be able to access it through the ORM, e.g.

        $list = $this->ExtraData();

        if ($list && $list->exists()) {

            error_log($list->max('SortOrder'));

        }

If you need to get the list from a class you can do something similar to
        $extraData = Page::get()->relation('ExtraData');
        error_log($extraData->max('SortOrder'));

Tony Air

unread,
Nov 13, 2014, 2:48:06 PM11/13/14
to silverst...@googlegroups.com
it won't work if you have 2 fields: ProductPage_ProductItems.SortOrder and ProductItem.SortOrder

Will Morgan

unread,
Nov 14, 2014, 1:33:27 PM11/14/14
to silverst...@googlegroups.com
Hi Tony,

It's worth raising a GitHub issue about this sort of problem. I'm wondering if a core team member more experienced in the DataList API might be able to pick this up... Damian? ;-)

Will

Tony Air

unread,
Nov 14, 2014, 1:41:00 PM11/14/14
to silverst...@googlegroups.com
Hi Will, I think it can be fixed pretty easy we just need to replace MAX("$val") with MAX(Convert::raw2sql($val)) I will submit issue to GitHub

-- 
Best regards, Tony Air
CEO, TWDA New Castle LLC

E-mail: to...@twma.pro
Skype: a2nt.fd
http://twma.pro
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages