'Link table component field queries use chained left
joins + distinct'

@unittest.skipIf((not current.deployment_settings.has_module('project')), 'project    module    disabled')
def testGetQueryJoinsLinkedComponentField(self):

    s3db = current.s3db
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    resource = s3db.resource('project_project')
    q = (FS('task.description') == 'test')
    (joins, distinct) = q._joins(resource)
    assertEqual(joins, {})
    assertTrue(distinct)
    project_project = resource.table
    project_task_project = s3db.project_task_project
    project_task = s3db.project_task
    expected_l = project_task_project.on(((project_task_project.project_id == project_project.id) & (project_task_project.deleted != True)))
    expected_r = project_task.on((project_task_project.task_id == project_task.id))
    (joins, distinct) = q._joins(resource, left=True)
    assertEqual(joins.keys(), ['project_task'])
    assertTrue(isinstance(joins['project_task'], list))
    assertEqual(len(joins['project_task']), 2)
    assertEqual(str(joins['project_task'][0]), str(expected_l))
    assertEqual(str(joins['project_task'][1]), str(expected_r))
    assertTrue(distinct)
