我有一张看起来像这样的桌子......
class Company(db.Model):
__tablename__ = 'company'
company_id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
slug = db.Column(db.String)
tags = db.Column(ARRAY(db.Integer), index=True)
investments = relationship("Investment", back_populates="company")
我想编写一个查询,返回数组(标记列)中具有某个整数(比如6)的所有行,我尝试了以下this
(1) investors = db.session.query(Investor).filter(Company.tags.any(6)).all()
(2) investors = db.session.query(Investor).filter(Company.tags.contains([6]))
(1)给我以下错误......
ProgrammingError: (ProgrammingError) missing FROM-clause entry for table "company"
LINE 3: WHERE 6 = ANY (company.tags)
(2)给我意想不到的行为。它要么不返回所有信息,要么全部返回。过滤器不起作用。 ^