Closed brochington closed 5 years ago
The behavior here is correct. The query you wrote is id IN (query returning int4[])
, which would error at runtime with:
ERROR: 42883: operator does not exist: integer = integer[]
LINE 1: select 1 in (select array[1,2,3]);
I'd expect = ANY((query))
to work here, but PG doesn't appear to recognize the second set of parenthesis as turning a query into a single value (which is unfortunate, since the corresponding Diesel query would compile...)
Something like this would probably work for you: .filter(array(OrgQuery::id).is_contained_by(q.single_value()))
. You could also use unnest
:
sql_function!(fn unnest<T>(x: Array<T>) -> T);
// ...
.select(unnest(UserQuery::orgs))
I'm closing this, as there doesn't appear to be a bug here. If you need additional help, please ask in Gitter or Discourse.
Setup
Versions
Feature Flags
Problem Description
Given the following code:
What are you trying to accomplish?
I would like to get all the orgs that belong to the orgs array of a particular user.
What is the expected output?
I should see a vec of orgs.
FWIW, I've chatted briefly with George Semmler (@weiznich) on Gitter, and he believes this should be working.
What is the actual output?
no output.
Are you seeing any additional errors?
This results in an error in the
.filter(OrgQuery::id.eq_any(q))
line of:Steps to reproduce
Checklist