-
-
Notifications
You must be signed in to change notification settings - Fork 228
Open
Labels
Description
Currently we only have in_subquery to handle subqueries. It would be nice to also have gte_subquery, or more generally an Expr::subquery to express more operators on subqueries.
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::col(Char::SizeW).in_subquery(
Query::select()
.expr(Expr::cust("3 + 2 * 2"))
.take()
))
.to_owned();Corresponding PostgreSQL :
SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" IN (SELECT 3 + 2 * 2)Feature request
I don't think there's currently a solution to do the following :
SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" >= (SELECT "size_w" FROM "character" WHERE "id" = "foo")Possible solutions
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::col(Char::SizeW).gte_subquery(
Query::select()
.column(Char::SizeW)
.from(Char::Table)
.and_where(Char::Id.eq("foo"))
.take()
))
.to_owned();let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::col(Char::SizeW).gte(Expr::subquery(
Query::select()
.column(Char::SizeW)
.from(Char::Table)
.and_where(Char::Id.eq("foo"))
.take()
)))
.to_owned();Originally posted by @SteelAlloy in #673