I have similar problem to this one (most similar is the answer with &&
). For postgres, I would like to get the intersection of array column and python list. I've tried to do that with &&
operator:
query(Table.array_column.op('&&')(cast(['a', 'b'], ARRAY(Unicode)))).filter(Table.array_column.op('&&')(cast(['a', 'b'], ARRAY(Unicode))))
but it seems that op('&&')
return bool
type (what has sense for filter) not the intersection.
So for table data:
id | array_column
1 {'7', 'xyz', 'a'}
2 {'b', 'c', 'd'}
3 {'x', 'y', 'ab'}
4 {'ab', 'ba', ''}
5 {'a', 'b', 'ab'}
I would like to get:
id | array_column
1 {'a'}
2 {'b'}
5 {'a', 'b'}