Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting eager loaded elements only works with "order" not "orderBy" #3109

Closed
kristiansp opened this issue Jul 18, 2018 · 1 comment
Closed

Comments

@kristiansp
Copy link

kristiansp commented Jul 18, 2018

Description

It seems that ordering eager loaded elements only works with the deprecated order, not the new orderBy. Thus the following code returns the wanted result, sorting the shows in ascending order by showTime:

{% set currentMovies = craft.entries({
                         section: 'movies',
                         type:    'movie',
                         orderBy:   'startingDate asc',
                         limit:   null,
                         with: [
                           ['shows', { order: 'showTime asc' }],
                           'poster',
                           'stills'
                         ]
                       }).all()
%}

It will then throw a deprecation warning with the following origin:
/Applications/MAMP/htdocs/craft3/vendor/craftcms/cms/src/elements/db/EntryQuery.php:216

Whereas the following code does not sort the shows:

{% set currentMovies = craft.entries({
                         section: 'movies',
                         type:    'movie',
                         orderBy:   'startingDate asc',
                         limit:   null,
                         with: [
                           ['shows', { orderBy: 'showTime asc' }],
                           'poster',
                           'stills'
                         ]
                       }).all()
%}

Steps to reproduce

  1. Make element query with eager loaded elements
  2. Sort the eager loaded elements by a custom field

Additional info

  • Craft version: Craft Pro 3.0.15
  • PHP version: 7.1.12
  • Database driver & version: MySQL 5.6.38
  • Plugins & versions: N/A
@brandonkelly
Copy link
Member

Thanks! Fixed that for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants