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

Both Query.orderBy and UseCollect.sortBy are broken #1858

Open
daniser opened this issue May 23, 2024 · 1 comment
Open

Both Query.orderBy and UseCollect.sortBy are broken #1858

daniser opened this issue May 23, 2024 · 1 comment
Labels
bug Something isn't working needs reproduction Needs a working reproduction of the bug

Comments

@daniser
Copy link
Contributor

daniser commented May 23, 2024

Environment

No response

Reproduction

Unfortunately I have no free time right now to craft a minimal reproduction. I will return here and make it when I'll have spare time.

Describe the bug

I have complex sorting logic which worked in Pinia ORM 1.7.2 but stopped working in 1.9.1. It's no more reactive, and sorting order differs between versions. I don't know exactly what's wrong, it needs further investigation.

I just put this information here so @CodeDredd and others know there's a problem and maybe dig into it if interested.

Additional context

My usage (I know it's cumbersome but I can't do minimal repro at this time):

<script setup lang="ts">
import { useRepo } from "pinia-orm";
import { useCollect } from "pinia-orm/helpers";

const operatorRepo = computed(() => useRepo(OperatorRepository));
const ticketRepo = computed(() => useRepo(TicketRepository));

const sortedOperators = computed(() =>
    useCollect(
        operatorRepo.value
            .with("tickets", (query) => {
                query.with("category").where("meta", metaFilter).orderBy(mode.value, "desc");
            })
            .whereHas("tickets")
            .orWhere((operator: OperatorModel) => !options.hideEmpty && operator.online)
            .get(),
    ).sortBy([
        ["online", "desc"],
        ["ready", "desc"],
        ["free_slots", "desc"],
        ["ticket_count", "asc"],
        ["name", "asc"],
    ]),
);

const sortedTickets = computed(() =>
    ticketRepo.value.unbound().with("category").where("meta", metaFilter).orderBy(mode.value, "desc").get(),
);
</script>

Logs

No response

@CodeDredd
Copy link
Owner

@daniser Thank's for the head ups. Lookings forward for the reporduction, because with out it it's gonna hard to find and fix.

@CodeDredd CodeDredd added the bug Something isn't working label May 24, 2024
@CodeDredd CodeDredd added the needs reproduction Needs a working reproduction of the bug label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction Needs a working reproduction of the bug
Projects
None yet
Development

No branches or pull requests

2 participants