0
目前,我有以下查詢:明確指定 「FROM」 表
query = self.session.query(Student, School).join(
Person.student, aliased=True).join(
Student.school, aliased=True).filter(
Person.id == 1)
來編譯這個SQL。
SELECT student.id AS student_id, student.school_id AS student_school_id, student.person_id AS student_person_id, school.id AS school_id, school.name AS school_name
FROM student, school, person JOIN student AS student_1 ON person.id = student_1.person_id JOIN school AS school_1 ON school_1.id = student_1.school_id
WHERE person.id = :id_1
我希望查詢保持完全,因爲它是,但我想從語句從Person
模型是專。因此,像
SELECT * FROM person JOIN ... WHERE person.id = :id_1
我覺得aliased
kwarg是搞亂了的狀態。 kwarg刪除了aliased
修復了這種行爲,但我需要別名kwarg作爲特殊用例。如何從「FROM」語句中刪除student
和school
表。