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

Types issue: grouping by added field #132

Closed
soanvig opened this issue Aug 8, 2022 · 3 comments
Closed

Types issue: grouping by added field #132

soanvig opened this issue Aug 8, 2022 · 3 comments
Labels
bug Something isn't working typescript Related to Typescript

Comments

@soanvig
Copy link
Contributor

soanvig commented Aug 8, 2022

If I have table let's say { tableName: { column1: string }} then in .groupBy I can only group by column1 string, which is fine.

However if I add something to a query via .select().as('column2') then I cannot group by this column.

This would be effectively something like this SQL:

SELECT 'Text' as field, COUNT(*) GROUP BY field;

In postgres this works, but I cannot to make it working in Kysely types. I have to cast as any (or just sql.ref):

.groupBy([sql.ref('field')])

Looks like a bug to me or maybe it's postgres specific that's why it is not implemented.

@koskimas
Copy link
Member

koskimas commented Aug 8, 2022

Yep, that's a bug. I'll fix it right away. Thanks for opening the issue!

@koskimas
Copy link
Member

koskimas commented Aug 8, 2022

Fixed in 0.21.1

@soanvig
Copy link
Contributor Author

soanvig commented Aug 9, 2022

Fell in love with this library, very well designed in my opinion :)

@igalklebanov igalklebanov added bug Something isn't working typescript Related to Typescript labels Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript Related to Typescript
Projects
None yet
Development

No branches or pull requests

3 participants