kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.22k stars 259 forks source link

Feature request in adding ExecuteTakeFirstOrThrow #890

Closed shivan-eyespace closed 6 months ago

shivan-eyespace commented 6 months ago

I have had a look through closed issues and wasn't able to find something like this.

So far we have execute(), executeTakeFirst() and executeTakeFirstOrThrow().

We are wondering if there is a take one and one only else throw if you SQL gets more than one row result.

This would be simliar to sqlalchemy's .one() (https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Result.one) as opposed the .first() (and also one_or_none() - at most one result or no result else throw an error) methods.

thelinuxlich commented 6 months ago

I feel this is kind of feature creep

shivan-eyespace commented 6 months ago

I feel this is kind of feature creep

The equivalent for one_or_none() would be too much burden. I'm wondering if the .one() would be popular.

koskimas commented 6 months ago

I feel this is kind of feature creep

Agreed.