'Test correct handling of ambiguous rows in select'

def testCollapseRows(self):

    s3db = current.s3db
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    otable = s3db.org_organisation
    ftable = s3db.org_office
    query = ((otable.uuid == 'DATESTORG') & (ftable.organisation_id == otable.id))
    rows = current.db(query).select(otable.id, otable.name, ftable.id, ftable.name)
    assertEqual(len(rows), 2)
    resource = s3db.resource('org_organisation', uid='DATESTORG')
    list_fields = ['name', 'office.name']
    data = resource.select(list_fields, count=True, getids=True)
    assertEqual(data.numrows, 1)
    assertEqual(len(data.ids), 1)
    rows = data.rows
    assertEqual(len(rows), 1)
    office_names = rows[0]['org_office.name']
    assertTrue(isinstance(office_names, list))
    assertEqual(len(office_names), 2)
    assertTrue(('DATestOffice1' in office_names))
    assertTrue(('DATestOffice2' in office_names))
    data = resource.select(list_fields, represent=True)
    rows = data.rows
    assertEqual(len(rows), 1)
    office_names = rows[0]['org_office.name']
    assertTrue(isinstance(office_names, basestring))
    office_names = [s.strip() for s in office_names.split(',')]
    assertEqual(len(office_names), 2)
    assertTrue(('DATestOffice1' in office_names))
    assertTrue(('DATestOffice2' in office_names))
