extend bw compat test for impossible left-joins

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/catalog_join@42348 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cbd160d0
...@@ -4347,15 +4347,7 @@ VALUES ...@@ -4347,15 +4347,7 @@ VALUES
result = connector.manage_test('select 1 as foo;') result = connector.manage_test('select 1 as foo;')
self.assertEquals(1, result[0].foo) self.assertEquals(1, result[0].foo)
def test_SelectDictWithDynamicRelatedKey(self, quiet=quiet, run=run_all_test): def _createSomeGroupCategories(self):
if not run: return
if not quiet:
message = 'Select Dict With Dynamic Related Key'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
# Create some group categories
portal = self.getPortal()
portal_category = self.getCategoryTool() portal_category = self.getCategoryTool()
group_category = portal_category.group group_category = portal_category.group
group_data_map = dict(nexedi=('Nexedi', 'Nexedi Group'), group_data_map = dict(nexedi=('Nexedi', 'Nexedi Group'),
...@@ -4368,8 +4360,18 @@ VALUES ...@@ -4368,8 +4360,18 @@ VALUES
group = group_category.newContent(id=group_id) group = group_category.newContent(id=group_id)
group.edit(title=title, description=description) group.edit(title=title, description=description)
# Create some orgs associated with varying association with those groups def test_SelectDictWithDynamicRelatedKey(self, quiet=quiet, run=run_all_test):
module = portal.getDefaultModule('Organisation') if not run: return
if not quiet:
message = 'Select Dict With Dynamic Related Key'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
self._createSomeGroupCategories()
# Create some orgs associated with varying association with the
# groups created above.
module = self.portal.getDefaultModule('Organisation')
# org1 has no groups # org1 has no groups
org1 = module.newContent(portal_type='Organisation', title='org1') org1 = module.newContent(portal_type='Organisation', title='org1')
# org2 has group nexedi # org2 has group nexedi
...@@ -4502,6 +4504,19 @@ VALUES ...@@ -4502,6 +4504,19 @@ VALUES
# shouldn't work # shouldn't work
self.assertRaises(RuntimeError, lambda: catalog.searchResults(**query_lj)) self.assertRaises(RuntimeError, lambda: catalog.searchResults(**query_lj))
# Neither should it work if a left-join is attempted in a column
# that has proper related-key rendering, but is present in the
# same query as a column that hasn't, as the whole query is
# converted into implicit inner joins.
self.tic()
query_lj.update(left_join_list=('strict_group_title',),
select_dict=('strict_group_title',))
self.assertRaises(RuntimeError, lambda: catalog.searchResults(**query_lj))
# though it should work on queries that don't use the broken related-key
del query_lj['grand_parent_portal_type']
self.assertEqual([x.getObject() for x in catalog.searchResults(**query_lj)],
[org_a.default_address])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Catalog)) suite.addTest(unittest.makeSuite(TestERP5Catalog))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment