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

db.max() return type is always number #140

Open
pocin opened this issue Feb 7, 2023 · 1 comment
Open

db.max() return type is always number #140

pocin opened this issue Feb 7, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@pocin
Copy link

pocin commented Feb 7, 2023

Hey! I just noticed that doing

const q = db.max('table', db.all, {colums: ["end_date"])

compiles to a correct query

q.compile()
{
  text: 'SELECT max("end_date") AS result FROM "table"',
  values: []
}

but the return type is number which is not always the case (could be date or even string fwiw).

I would expect the return type to be inferred from the schema, but not sure if this is feasible.

In this particular case i can do

db.select('table', {order: {by: ['end_date'], direction: 'DESC'},limit: 1})

which is correctly typed, but wanted to report anyway

@jawj
Copy link
Owner

jawj commented Feb 15, 2023

Thanks, this is a good point — I had originally envisaged this only as having numeric return values, but of course you are right that it's more widely applicable.

@jawj jawj added the enhancement New feature or request label Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants