I can't give date or datetime obj as value to compare in dict query, can you please help me regarding this
raviteja1766 opened this issue · 1 comments
raviteja1766 commented
import dictquery
dict_ = {
"a": "where is the",
"b": "Hello is",
"c": datetime(2022, 11, 18, 0,0,0),
"d": date(2022, 11, 18)
}
dictquery.match(dict_, "d
<= date(2022, 11, 18)")
cyberlis commented
Right now you can only compare datetime field to NOW
dictquery.match(dict_, "c <= NOW")
As workaround you can store value with which you want compare to in separate field
from datetime import datetime, date
import dictquery
dict_ = {
"data":{
"a": "where is the",
"b": "Hello is",
"c": datetime(2022, 11, 18, 0,0,0),
"d": date(2022, 11, 18)
},
"constants": {
"somedate": date(2022, 11, 23)
}
}
dictquery.match(dict_, "`data.d` <= `constants.somedate`")