@ -117,21 +117,40 @@ abstract class GoogleTaskDao {
@Query("SELECT google_tasks.*, gt_remote_order AS primary_sort, NULL AS secondary_sort FROM google_tasks JOIN tasks ON tasks._id = gt_task WHERE gt_parent = 0 AND gt_list_id = :listId AND tasks.deleted = 0 UNION SELECT c.*, p.gt_remote_order AS primary_sort, c.gt_remote_order AS secondary_sort FROM google_tasks AS c LEFT JOIN google_tasks AS p ON c.gt_parent = p.gt_task JOIN tasks ON tasks._id = c.gt_task WHERE c.gt_parent > 0 AND c.gt_list_id = :listId AND tasks.deleted = 0 ORDER BY primary_sort ASC, secondary_sort ASC")
+" WHERE p.gt_remote_id = google_tasks.gt_remote_parent"
+" AND p.gt_list_id = google_tasks.gt_list_id "
+" AND p.gt_deleted = 0),"
+" 0)"
+" WHERE gt_moved = 0")
@Query("""
UPDATEgoogle_tasks
SETgt_parent=IFNULL((SELECTgt_task
FROMgoogle_tasksASp
WHEREgoogle_tasks.gt_remote_parentISNOTNULL
ANDgoogle_tasks.gt_remote_parent!=''
ANDp.gt_remote_id=google_tasks.gt_remote_parent
ANDp.gt_list_id=google_tasks.gt_list_id
ANDp.gt_deleted=0),0)
WHEREgt_moved=0
""")
abstractsuspendfunupdateParents()
@Query("UPDATE google_tasks SET gt_parent = IFNULL((SELECT gt_task FROM google_tasks AS p WHERE p.gt_remote_id = google_tasks.gt_remote_parent), 0) WHERE gt_list_id = :listId AND gt_moved = 0")
@Query("""
UPDATEgoogle_tasks
SETgt_parent=IFNULL((SELECTgt_task
FROMgoogle_tasksASp
WHEREgoogle_tasks.gt_remote_parentISNOTNULL
ANDgoogle_tasks.gt_remote_parent!=''
ANDp.gt_remote_id=google_tasks.gt_remote_parent
ANDp.gt_list_id=google_tasks.gt_list_id
ANDp.gt_deleted=0),0)
WHEREgt_list_id=:listId
ANDgt_moved=0
""")
abstractsuspendfunupdateParents(listId:String)
@Query("UPDATE google_tasks SET gt_remote_parent = :parent, gt_remote_order = :position WHERE gt_remote_id = :id")