I'm stuck at a specific problem with SQLAlchemy. Basically, I have a table with a column that is a nested array ({{filename1, file_url1}, {filename2, file_url2}}
).
I've managed to write a filter query to that searches in the first element of all arrays (so in this case, by filename) using an ILIKE
operator.
Yet, I have a problem with proper querying ALL of the arrays, as the [:]
slicing operator produces a [NULL:NULL]
slice in the compiled query, while I need a simple [:]
as this is something that is supported by PostgreSQL.
The query in SQLAlchemy looks like this
cast(DataStorage.result_files[:][1], sql_string).ilike(f"%{request.args.get('result_files', '')}%")
But produces CAST(data_storage.result_files[NULL:NULL][%(param_1)s] AS VARCHAR) ILIKE %(param_2)s
, instead of CAST(data_storage.result_files[:][%(param_1)s] AS VARCHAR) ILIKE %(param_2)s
When the result_files[:][1]
's first slice is set to a specific slice range, it works perfectly, but I have a problem with [:]
. Is there a simple solution for passing [:]
as is when the query is compiled?