Construct an array from the results a subquery in postgres? #588
Unanswered
kyle-mccarthy
asked this question in
Q&A
Replies: 1 comment
-
Hey @kyle-mccarthy, welcome to SeaQL! Sorry for the delay. Something like this? #[derive(Iden)]
#[iden = "ARRAY"]
pub struct ArrayFunc;
let sub_select = Query::select()
.expr(Expr::asterisk())
.from(Char::Table)
.to_owned();
let select = Query::select()
.expr(Func::cust(ArrayFunc).arg(SimpleExpr::SubQuery(
None,
Box::new(sub_select.into_sub_query_statement()),
)))
.to_owned();
assert_eq!(
select.to_string(PostgresQueryBuilder),
r#"SELECT ARRAY((SELECT * FROM "character"))"#
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to create an array from the results of a subquery using the postgres-array feature?
Simple example:
Returns:
{1,2,3,4}
The last paragraph in this section of the postgres docs discusses it.
Beta Was this translation helpful? Give feedback.
All reactions