Python SQLAlchemy';比较器';对象没有属性';有U键';
我正在使用JSON SQLAlchemy列,我的查询语句需要'has_key'属性,但显然我的'Comparator'对象没有这个属性Python SQLAlchemy';比较器';对象没有属性';有U键';,python,json,postgresql,sqlalchemy,Python,Json,Postgresql,Sqlalchemy,我正在使用JSON SQLAlchemy列,我的查询语句需要'has_key'属性,但显然我的'Comparator'对象没有这个属性 Transaction.query.filter(Transaction.fields.has_key('issuername')).all() 其中Transaction.fields是一列(JSON)。我得到错误“AttributeError:与Transaction.fields关联的'InstrumentedAttribute'对象和'Comparat
Transaction.query.filter(Transaction.fields.has_key('issuername')).all()
其中Transaction.fields是一列(JSON)。我得到错误“AttributeError:与Transaction.fields关联的'InstrumentedAttribute'对象和'Comparator'对象都没有属性'has_key'。我的SQLAlchemy是最新版本1.09。我构建这个查询是错误的吗
有_键
操作员特定于
JSONB
类型包括JSON
提供的所有操作,包括
索引操作的行为相同。它还增加了额外的功能
特定于JSONB
的运算符,包括JSONB.Comparator.has_key()
,
JSONB.Comparator.has_all()
,JSONB.Comparator.has_any()
,
JSONB.Comparator.contains()
,和JSONB.Comparator.contained\u by()
对于JSON列,您可以使用->
PostgreSQL运算符(按键获取JSON对象字段)
Transaction.query.filter(Transaction.fields.op('->')('issuername')!=None).all()