我有兩個瓶,SQLAlchemy的模型和respectives燒瓶不寧API端點如下:燒瓶躁動無法構造查詢
class Person(db.Model):
person_id = db.Column(db.Integer, primary_key=True)
document = db.Column(db.String(), unique=True)
name = db.Column(db.String(45))
class Student(db.Model):
student_id = db.Column(db.Integer, primary_key=True)
person_id = db.Column(db.Integer, db.ForeignKey('person.person_id'))
code = db.Column(db.String(45))
person = db.relationship('Person', backref=db.backref('students', lazy='dynamic'))
manager.create_api(Person, methods=['GET', 'POST'])
manager.create_api(Student, methods=['GET', 'POST'])
這些URL正常工作:
http://localhost:8080/api/person
http://localhost:8080/api/student
但是,當我嘗試進行搜索查詢爲在official docs描述的相關模型,我正在{ "message": "Unable to construct query" }
對這些請求:
http://localhost:8080/api/person?q={"filters":[{"name":"students__code","op":"eq","val":"1"}]}
http://localhost:8080/api/person?q={"filters":[{"name":"students","op":"has","val":{"name":"code","op":"eq","val":"1"}}]}
http://localhost:8080/api/student?q={"filters":[{"name":"person__document","op":"eq","val":"111"}]}
http://localhost:8080/api/student?q={"filters":[{"name":"person","op":"any","val":{"name":"document","op":"eq","val":"111"}}]}
我使用Flask 0.10.1,Flask-SQLAlchemy 2.0,Flask-Restless 0.17.0,SQLAlchemy 1.0.6和Python 2.7。
根據這一點,我沒有在我的模型發現錯誤。 –
我已經更新了答案。 – doru