Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SQLAlchemy';比较器';对象没有属性';有U键';_Python_Json_Postgresql_Sqlalchemy - Fatal编程技术网

Python SQLAlchemy';比较器';对象没有属性';有U键';

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

我正在使用JSON SQLAlchemy列,我的查询语句需要'has_key'属性,但显然我的'Comparator'对象没有这个属性

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()