예제 #1
0
파일: test_osv.py 프로젝트: vak0160/odoo-1
 def test_mixed_query_chained_explicit_implicit_joins(self):
     query = Query()
     query.tables.extend(['"product_product"', '"product_template"'])
     query.where_clause.append(
         "product_product.template_id = product_template.id")
     query.add_join(("product_template", "product_category", "categ_id",
                     "id", "categ_id"),
                    implicit=False,
                    outer=False)  # add normal join
     query.add_join(("product_template__categ_id", "res_user", "user_id",
                     "id", "user_id"),
                    implicit=False,
                    outer=True)  # CHAINED outer join
     query.tables.append('"account.account"')
     query.where_clause.append(
         "product_category.expense_account_id = account_account.id"
     )  # additional implicit join
     self.assertEquals(
         query.get_sql()[0].strip(),
         """"product_product","product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") LEFT JOIN "res_user" as "product_template__categ_id__user_id" ON ("product_template__categ_id"."user_id" = "product_template__categ_id__user_id"."id"),"account.account" """
         .strip())
     self.assertEquals(
         query.get_sql()[1].strip(),
         """product_product.template_id = product_template.id AND product_category.expense_account_id = account_account.id"""
         .strip())
예제 #2
0
 def test_raise_missing_lhs(self):
     query = Query()
     query.tables.append('"product_product"')
     self.assertRaises(
         AssertionError,
         query.join,
         ("product_template", "product_category", "categ_id", "id"),
         outer=False)
예제 #3
0
파일: test_osv.py 프로젝트: 0k/OpenUpgrade
 def test_query_chained_explicit_joins(self):
     query = Query()
     query.tables.extend(['"product_product"', '"product_template"'])
     query.where_clause.append("product_product.template_id = product_template.id")
     query.add_join(("product_template", "product_category", "categ_id", "id", "categ_id"), implicit=False, outer=False)  # add normal join
     query.add_join(("product_template__categ_id", "res_user", "user_id", "id", "user_id"), implicit=False, outer=True)  # CHAINED outer join
     self.assertEquals(query.get_sql()[0].strip(),
         """"product_product","product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") LEFT JOIN "res_user" as "product_template__categ_id__user_id" ON ("product_template__categ_id"."user_id" = "product_template__categ_id__user_id"."id")""".strip())
     self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id""".strip())
예제 #4
0
 def test_basic_query(self):
     query = Query()
     query.tables.extend(['"product_product"','"product_template"'])
     query.where_clause.append("product_product.template_id = product_template.id")
     query.join(("product_template", "product_category", "categ_id", "id"), outer=False) # add normal join
     query.join(("product_product", "res_user", "user_id", "id"), outer=True) # outer join
     self.assertEquals(query.get_sql()[0].strip(),
         """"product_product" LEFT JOIN "res_user" ON ("product_product"."user_id" = "res_user"."id"),"product_template" JOIN "product_category" ON ("product_template"."categ_id" = "product_category"."id") """.strip())
     self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id""".strip())
예제 #5
0
 def test_mixed_query_chained_explicit_implicit_joins(self):
     query = Query()
     query.tables.extend(['"product_product"','"product_template"'])
     query.where_clause.append("product_product.template_id = product_template.id")
     query.join(("product_template", "product_category", "categ_id", "id"), outer=False) # add normal join
     query.join(("product_category", "res_user", "user_id", "id"), outer=True) # CHAINED outer join
     query.tables.append('"account.account"')
     query.where_clause.append("product_category.expense_account_id = account_account.id") # additional implicit join
     self.assertEquals(query.get_sql()[0].strip(),
         """"product_product","product_template" JOIN "product_category" ON ("product_template"."categ_id" = "product_category"."id") LEFT JOIN "res_user" ON ("product_category"."user_id" = "res_user"."id"),"account.account" """.strip())
     self.assertEquals(query.get_sql()[1].strip(), """product_product.template_id = product_template.id AND product_category.expense_account_id = account_account.id""".strip())
예제 #6
0
 def test_query_chained_explicit_joins(self):
     query = Query()
     query.tables.extend(['"product_product"', '"product_template"'])
     query.where_clause.append(
         "product_product.template_id = product_template.id")
     query.join(("product_template", "product_category", "categ_id", "id"),
                outer=False)  # add normal join
     query.join(("product_category", "res_user", "user_id", "id"),
                outer=True)  # CHAINED outer join
     self.assertEquals(
         query.get_sql()[0].strip(),
         """"product_product","product_template" JOIN "product_category" ON ("product_template"."categ_id" = "product_category"."id") LEFT JOIN "res_user" ON ("product_category"."user_id" = "res_user"."id")"""
         .strip())
     self.assertEquals(
         query.get_sql()[1].strip(),
         """product_product.template_id = product_template.id""".strip())
예제 #7
0
파일: test_osv.py 프로젝트: vak0160/odoo-1
 def test_basic_query(self):
     query = Query()
     query.tables.extend(['"product_product"', '"product_template"'])
     query.where_clause.append(
         "product_product.template_id = product_template.id")
     query.add_join(("product_template", "product_category", "categ_id",
                     "id", "categ_id"),
                    implicit=False,
                    outer=False)  # add normal join
     query.add_join(
         ("product_product", "res_user", "user_id", "id", "user_id"),
         implicit=False,
         outer=True)  # outer join
     self.assertEquals(
         query.get_sql()[0].strip(),
         """"product_product" LEFT JOIN "res_user" as "product_product__user_id" ON ("product_product"."user_id" = "product_product__user_id"."id"),"product_template" JOIN "product_category" as "product_template__categ_id" ON ("product_template"."categ_id" = "product_template__categ_id"."id") """
         .strip())
     self.assertEquals(
         query.get_sql()[1].strip(),
         """product_product.template_id = product_template.id""".strip())