I have a datamodel where I store a list of values separated by comma (1,2,3,4,5...).
In my code, in order to work with
arrays instead of
string, I have defined the model like this one:
class MyModel(db.Model): pk = db.Column(db.Integer, primary_key=True) __fake_array = db.Column(db.String(500), name="fake_array") @property def fake_array(self): if not self.__fake_array: return return self.__fake_array.split(',') @fake_array.setter def fake_array(self, value): if value: self.__fake_array = ",".join(value) else: self.__fake_array = None
This works perfect and from the point of view of my source code "fake_array" is an array, It's only transformed into
string when it's stored in database.
The problem appears when I try to filter by that field. Expressions like this doesn't work:
It seems that I cant filter using the
SqlAlchemy query model.
What can I do here? Is there any way to filter this kind of fields? Is there is a better pattern for the "fake_array" problem?