should dup behavior be reverted?
cyjake opened this issue · comments
Chen Yangjian commented
The design of dup is mostly to solve confusing usages like below:
const query = Post.where({ published: true });
// SELECT * FROM posts WHERE published = 1 LIMIT 0,20;
const posts = await query.limit(pageSize).offset((page - 1) * pageSize);
// SELECT COUNT(*) FROM posts WHERE published = 1;
const count = await query.count();
Chen Yangjian commented
the bad part of this design is if user wants to construct query conditionally, they'd have to define the query as mutable, such as:
let query = Post.where({ published: true });
query = query.where('commentCount > ?', commentCount);