Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Distinct and OrderBy Unindexed field #269

@falahati

Description

@falahati

A simple query as follow works great:

await db
    .select(lf.fn.distinct(table.id))
    .from(table)
    .orderBy(table.id, lf.Order.ASC)
    .limit(10)
    .exec();

or even by an string field:

await db
    .select(lf.fn.distinct(table.id))
    .from(table)
    .orderBy(table.title, lf.Order.ASC)
    .limit(10)
    .exec();

But ordering by date doesn't work in my case:

await db
    .select(lf.fn.distinct(table.id))
    .from(table)
    .orderBy(table.created, lf.Order.ASC)
    .limit(10)
    .exec();

By not working I mean it gives me a result that doesn't change if I modify the order to DESC or ASC. It just returns a static result as if the date created is zero or the same number for all rows. Checked manually and each row does in fact have a different value.
Removing the distinct function fixes the problem.

If you need any additional information, please ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions