hediet / ts-typed-sql

A fully typed sql builder. Not maintained anymore, use it for your inspiration.
https://hediet.github.io/ts-typed-sql/
54 stars 4 forks source link

single / singleOrUndefined misleadingly add limit 2 to queries with limit 1 leading to "More than one row returned" #41

Open phiresky opened 4 years ago

phiresky commented 4 years ago

The following query throws "More than one row returned":

db.singleOrUndefined(select(tbl.$all).from(tbl).where({a:b}).orderBy(tbl.id.desc()).limit(1))

Even though it does only return one row because of the limit(1).

Because the library replaces the limit 1 with a limit 2. Should probably only do that if the query does not already have a limit clause.