Been at this for a week now with no results and nothing on the web to help.

Question is, how do you query an array of values the same way '.contains' looks for a value in an array saved in the db.

In this example, I want to query all the rows that contain "white" and rows with "black"

This is the example of data in a database for simplicity. 6 Rows - "red" has 1 result, "white" has 3 results, "black" has 4 results

id|color|
-------
1|red,white,blue|
2|black,white|
3|black|
4|white|
5|black|
6|black|

Here are some methods Iv tried with the results:

Using .in_ with array.

result = db.session.query(Model).filter(Model.color.in_((['white', 'black']))).all()

Result gives data for rows = 3,4,5,6

Using .contains with array.

result = db.session.query(Model).filter(Model.color.contains('white', 'black')).all()

Result TypeError: contains() takes exactly 2 arguments (3 given)

Using .like with array.

result = db.session.query(Model).filter(Model.color.like('%white%black%')).all()

Result gives data for row 2

Ultimately, the correct result should be all the rows since white and black are containing in the color column.

Thank you much in advanced,

0 Answers