So, I have a model like this:
class myModel(Base):
id = Column(Integer, primary_key=True)
border = Column(JSONB)
How can I query strings that don't have a border? I tried:
filter(myModel.border != None)
filter(myModel.border != 'null')
from sqlalchemy import null
filter(myModel.border != null())
The value is apparently stored postgresas JSON encoded null value . It definitely gets serialized back to python Nonewhen creating the instance, but I don't know how to request it. It looks like you can set none_as_nullin a column, i.e.:
Column(JSONB(none_as_null=True))
Which replaces JSON-encoded nullwith null, but this seems weird for all columns. What am I missing here?
edit: it should be mentioned that it is v0.9.8 sqlalchemy
source
share