hediet/ts-typed-sql

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

Opened this issue · 0 comments

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.