def test_apply(self): attrs = { 'context': { 'field': 'tests.title.boss', 'operator': 'exact', 'value': True }, 'view': { 'columns': [1], } } query = DataQuery(attrs) self.assertEqual(unicode(query.apply(tree=Employee).query), 'SELECT DISTINCT "tests_employee"."id", "tests_office"."location", "tests_title"."name" FROM "tests_employee" INNER JOIN "tests_title" ON ("tests_employee"."title_id" = "tests_title"."id") INNER JOIN "tests_office" ON ("tests_employee"."office_id" = "tests_office"."id") WHERE "tests_title"."boss" = True ') query = DataQuery({'view': {'ordering': [(1, 'desc')]}}) queryset = Employee.objects.all().distinct() self.assertEqual(unicode(query.apply(queryset=queryset).query), 'SELECT DISTINCT "tests_employee"."id", "tests_office"."location", "tests_title"."name" FROM "tests_employee" INNER JOIN "tests_office" ON ("tests_employee"."office_id" = "tests_office"."id") LEFT OUTER JOIN "tests_title" ON ("tests_employee"."title_id" = "tests_title"."id") ORDER BY "tests_office"."location" DESC, "tests_title"."name" DESC')
def test_apply(self): c = DataConcept.objects.get(fields__model_name='office', fields__field_name='location') attrs = { 'context': { 'field': 'tests.title.boss', 'operator': 'exact', 'value': True }, 'view': [{ 'concept': c.pk, 'visible': True, }], } query = DataQuery(attrs) self.assertEqual( unicode(query.apply(tree=Employee).query).replace(' ', ''), 'SELECT DISTINCT "tests_employee"."id", ' '"tests_office"."location" FROM ' '"tests_employee" INNER JOIN "tests_title" ON ' '("tests_employee"."title_id" = "tests_title"."id") INNER JOIN ' '"tests_office" ON ("tests_employee"."office_id" = ' '"tests_office"."id") WHERE "tests_title"."boss" = True '.replace( ' ', '')) query = DataQuery({'view': {'ordering': [(c.pk, 'desc')]}}) queryset = Employee.objects.all().distinct() self.assertEqual( unicode(query.apply(queryset=queryset).query).replace(' ', ''), 'SELECT DISTINCT "tests_employee"."id", ' '"tests_office"."location" FROM ' '"tests_employee" INNER JOIN "tests_office" ON ' '("tests_employee"."office_id" = "tests_office"."id") ' 'ORDER BY "tests_office"."location" DESC'.replace(' ', ''))
def test_apply(self): attrs = { 'context': { 'field': 'tests.title.boss', 'operator': 'exact', 'value': True }, 'view': { 'columns': [1], } } query = DataQuery(attrs) self.assertEqual( unicode(query.apply(tree=Employee).query), 'SELECT DISTINCT "tests_employee"."id", "tests_office"."location", "tests_title"."name" FROM "tests_employee" INNER JOIN "tests_title" ON ("tests_employee"."title_id" = "tests_title"."id") INNER JOIN "tests_office" ON ("tests_employee"."office_id" = "tests_office"."id") WHERE "tests_title"."boss" = True ' ) query = DataQuery({'view': {'ordering': [(1, 'desc')]}}) queryset = Employee.objects.all().distinct() self.assertEqual( unicode(query.apply(queryset=queryset).query), 'SELECT DISTINCT "tests_employee"."id", "tests_office"."location", "tests_title"."name" FROM "tests_employee" INNER JOIN "tests_office" ON ("tests_employee"."office_id" = "tests_office"."id") LEFT OUTER JOIN "tests_title" ON ("tests_employee"."title_id" = "tests_title"."id") ORDER BY "tests_office"."location" DESC, "tests_title"."name" DESC' )
def test_apply(self): c = DataConcept.objects.get(fields__model_name='office', fields__field_name='location') attrs = { 'context': { 'field': 'tests.title.boss', 'operator': 'exact', 'value': True }, 'view': [{ 'concept': c.pk, 'visible': True, }], } query = DataQuery(attrs) self.assertEqual( unicode(query.apply(tree=Employee).query).replace(' ', ''), 'SELECT DISTINCT "tests_employee"."id", ' '"tests_office"."location" FROM ' '"tests_employee" INNER JOIN "tests_title" ON ' '("tests_employee"."title_id" = "tests_title"."id") INNER JOIN ' '"tests_office" ON ("tests_employee"."office_id" = ' '"tests_office"."id") WHERE "tests_title"."boss" = True ' .replace(' ', '')) query = DataQuery({'view': {'ordering': [(c.pk, 'desc')]}}) queryset = Employee.objects.all().distinct() self.assertEqual( unicode(query.apply(queryset=queryset).query).replace(' ', ''), 'SELECT DISTINCT "tests_employee"."id", ' '"tests_office"."location" FROM ' '"tests_employee" INNER JOIN "tests_office" ON ' '("tests_employee"."office_id" = "tests_office"."id") ' 'ORDER BY "tests_office"."location" DESC'.replace(' ', ''))