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

on nested populate sort isn’t working #19210

Open
hassan-debug opened this issue Jan 12, 2024 · 0 comments
Open

on nested populate sort isn’t working #19210

hassan-debug opened this issue Jan 12, 2024 · 0 comments
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4

Comments

@hassan-debug
Copy link

hassan-debug commented Jan 12, 2024

Bug report

Required System information

  • Node.js version: 20
  • Strapi version:4.15
  • Database: postgres
  • Operating system:macOS
  • Is your project Javascript or Typescript: Javascript

Describe the bug

I Have collections of players and clubs which have manyToOne relation
i want to get player by id also populate its club and populate club players sort by fullname
but sort is not working on club players

below is my code

const player = await strapi.db.query("api::player.player").findOne({
     where: {
       $and: [{ slug: { $eq: slug } }, { publishedAt: { $not: null } }],
     },
     populate: {
       ProfilePicture: {
         populate: {
           image: true,
         },
       },
       club: {
         populate: {
           feature_image: { populate: true },
           players: {
             populate: {
               ProfilePicture: {
                 populate: {
                   image: true,
                 },
               },
             },
             sort: ['fullname:asc'],
           },
         },
       },
     },
   });

Response

`{
 "id": 3,
 "fullname": "Babar Azam",
 "height": "5 11",
 "weight": "89",
 "slug": "babar-azam",
 "ProfilePicture": {
   "id": 6,
   "image": {
     "id": 4,
     "name": "babar-azam-img.webp",
     "alternativeText": null,
     "caption": null,
     "width": 640,
     "height": 640,
   }
 },
 "club": {
   "id": 2,
   "name": "Lahore Qalander",
   "description": "Lahore Qalander club",
   "createdAt": "2024-01-12T10:21:37.378Z",
   "updatedAt": "2024-01-12T10:21:37.378Z"
   "players": [
     {
       "id": 3,
       "fullname": "Babar Azam",
       "height": "5 11",
       "weight": "89",
       
     },
     {
       "id": 5,
       "fullname": "Ahmad Hafeez",
       "height": "5 10",
       "weight": "89",
     }
   ]
 }
}`

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

``{
  "id": 3,
  "fullname": "Babar Azam",
  "height": "5 11",
  "weight": "89",
  "slug": "babar-azam",
  "ProfilePicture": {
    "id": 6,
    "image": {
      "id": 4,
      "name": "babar-azam-img.webp",
      "alternativeText": null,
      "caption": null,
      "width": 640,
      "height": 640,
    }
  },
  "club": {
    "id": 2,
    "name": "Lahore Qalander",
    "description": "Lahore Qalander club",
    "createdAt": "2024-01-12T10:21:37.378Z",
    "updatedAt": "2024-01-12T10:21:37.378Z"
    "players": [
 
      {
        "id": 5,
        "fullname": "Ahmad Hafeez",
        "height": "5 10",
        "weight": "89",
      }
,     {
        "id": 3,
        "fullname": "Babar Azam",
        "height": "5 11",
        "weight": "89",
        
      },
    ]
  }
}`
`
@Eventyret Eventyret added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4 labels Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4
Projects
Status: To be reviewed (Open)
Status: To review
Development

No branches or pull requests

2 participants