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

Support for case-insensitive sorting? #155

Open
Jordan-Turgeon opened this issue Jun 23, 2023 · 2 comments
Open

Support for case-insensitive sorting? #155

Jordan-Turgeon opened this issue Jun 23, 2023 · 2 comments

Comments

@Jordan-Turgeon
Copy link

Hello,

I'm wondering if there's a particular reason you cannot apply case-insensitive sorting for the .select methods?

This is useful in cases where you are loading with limit/offset and cannot rely on front-end sorting to accomplish this.

We have been able to do this using raw SQL but it would be a nice addition to the streamlined methods.

@jawj
Copy link
Owner

jawj commented Jun 24, 2023

Can you show me how you're doing this in raw SQL?

@Jordan-Turgeon
Copy link
Author

SELECT *
FROM "table"
ORDER BY "table"."column" COLLATE "ci"

Although I'm reading that this might not work on every SQL instance out of the box and there are many different options available to use with COLLATE depending on the system.

Maybe it could just be an optional parameter on the interface OrderSpecForTable.

interface OrderSpecForTable<T extends Table> {
    by: SQLForTable<T>;
    direction: 'ASC' | 'DESC';
    nulls?: 'FIRST' | 'LAST';
    collate?: string;
}

This way when the streamlined methods build the sql it can just be inserted if it's supported for the system running zapatos.

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