DB-API: get_family_handles(sort_handles=True) now fixed

This commit is contained in:
Doug Blank 2016-04-30 16:48:11 -04:00
parent 1c06a07156
commit 0a0a450b45

View File

@ -377,11 +377,21 @@ class DBAPI(DbGeneric):
If sort_handles is True, the list is sorted by surnames. If sort_handles is True, the list is sorted by surnames.
""" """
if sort_handles: if sort_handles:
self.dbapi.execute("""SELECT DISTINCT family.handle FROM family self.dbapi.execute("""SELECT f.handle FROM
JOIN person (SELECT family.*
ON family.father_handle = person.handle FROM family LEFT JOIN
ORDER BY person.primary_name__surname_list__0__surname, person AS father
person.primary_name__first_name;""") ON family.father_handle = father.handle LEFT JOIN
person AS mother
on family.mother_handle = mother.handle
order by (case when father.handle is null
then mother.primary_name__surname_list__0__surname
else father.primary_name__surname_list__0__surname
end),
(case when family.handle is null
then mother.primary_name__first_name
else father.primary_name__first_name
end)) AS f;""")
else: else:
self.dbapi.execute("SELECT handle FROM family;") self.dbapi.execute("SELECT handle FROM family;")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()