Answer the question
In order to leave comments, you need to log in
How to make an array selection in a JSON field?
Right now the query is only looking in the first element of the array, but I need to iterate over the entire array in a JSON field
attr = Column(db.JSON)
unit.attr = [
{'name': 'name1', 'date': '01.01.2018'},
{'name': 'name2', 'date': '01.01.2015'}
]
query = query.filter(Unit.attr[0]['date'].cast(db.String).cast(db.Date).between(date_begin, date_end))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question