Skip to content

Preview feature feedback: Order by Relations support (orderByRelation) #5438

Closed

Description

@matthewmueller

Please share your feedback about the orderByRelation functionality that was released in v2.16.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don't hesitate to ask them in the #prisma-client channel in the Prisma Slack.

Activity

  1. changed the title [-]Preview feature feedback: Order by Relations support (`orderByRelations`)[/-] [+]Preview feature feedback: Order by Relations support (`orderByRelation`)[/+] on Mar 10, 2021
  2. guerrerocarlos commented on Apr 23, 2021

    @guerrerocarlos

    The feature is working great, but if it could not only count the number of relations, but also sum, avg, min and max some specific attribute of the relations, it would make it a killer feature.

    For example, a very common use case:

    Top 10 students with the best grades

    await prisma.students.findMany({
      take: 10,
      orderBy: {
        exams: {
          avg: {
            points: 'desc' 
          }
        }
      },
    });
  3. Brandejs commented on May 27, 2021

    @Brandejs

    Hi,

    I prepare a simple project. There are 3 entities with composite keys. The last entity (TASK) has reference to Company and Project. I Can order tasks by CompanyName, but I cannot order them by ProjectName.

    prismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Invalidprisma.task.findMany() invocation: Error occurred during query execution: ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42804"), message: "argument of JOIN/ON must be type boolean, not type record", detail: None, hint: None, position: Some(Original(383)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_coerce.c"), line: Some(1156), routine: Some("coerce_to_boolean") }) }) }) at cb (/prisma-schema-orderby/node_modules/@prisma/client/runtime/index.js:35105:17) at processTicksAndRejections (internal/process/task_queues.js:93:5) { clientVersion: '2.23.0' }

    ISSUE: #7331

  4. janpio commented on May 28, 2021

    @janpio
    Contributor

    Can you split that into a new issue @Brandejs and also include the information asked for in the bug report template? That would be awesome. Thanks!

  5. andresribeiro commented on Jun 27, 2021

    @andresribeiro

    For me it doesn't work very well with skip. Not that this is a bug, but when the relation has the same quantity the order of the objects in the response may vary. I think this will only be solved when it becomes possible to sort by multiple fields

  6. added this to the 2.31.0 / 3.0.x milestone on Aug 19, 2021
  7. 2color commented on Sep 7, 2021

    @2color
    Contributor

    Closing this now that this has been released to General Availability in the 3.0.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: orderByRelationtopic: previewFeatures

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions