Commit d9f75517 authored by Julien Muchembled's avatar Julien Muchembled

SQLCatalog: revert behaviour change of getColumnIds and getTableIndex (cf 36144)

Both methods return a mutable value. Original behaviour was to copy the cached
value before returning it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36161 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e5f2793
...@@ -943,11 +943,7 @@ class Catalog(Folder, ...@@ -943,11 +943,7 @@ class Catalog(Folder,
@caching_instance_method(id='SQLCatalog.getColumnIds', @caching_instance_method(id='SQLCatalog.getColumnIds',
cache_factory='erp5_content_long') cache_factory='erp5_content_long')
def getColumnIds(self): def _getColumnIds(self):
"""
Calls the show column method and returns dictionnary of
Field Ids
"""
keys = {} keys = {}
for table in self.getCatalogSearchTableIds(): for table in self.getCatalogSearchTableIds():
field_list = self._getCatalogSchema(table=table) field_list = self._getCatalogSchema(table=table)
...@@ -962,10 +958,17 @@ class Catalog(Folder, ...@@ -962,10 +958,17 @@ class Catalog(Folder,
scriptable_tuple = scriptable.split('|') scriptable_tuple = scriptable.split('|')
scriptable = scriptable_tuple[0].strip() scriptable = scriptable_tuple[0].strip()
keys[scriptable] = None keys[scriptable] = None
keys = list(keys.keys()) keys = keys.keys()
keys.sort() keys.sort()
return keys return keys
def getColumnIds(self):
"""
Calls the show column method and returns dictionnary of
Field Ids
"""
return self._getColumnIds()[:]
@profiler_decorator @profiler_decorator
@transactional_cache_decorator('SQLCatalog.getColumnMap') @transactional_cache_decorator('SQLCatalog.getColumnMap')
@profiler_decorator @profiler_decorator
...@@ -1817,10 +1820,7 @@ class Catalog(Folder, ...@@ -1817,10 +1820,7 @@ class Catalog(Folder,
@caching_instance_method(id='SQLCatalog.getTableIndex', @caching_instance_method(id='SQLCatalog.getTableIndex',
cache_factory='erp5_content_long') cache_factory='erp5_content_long')
def getTableIndex(self, table): def _getTableIndex(self, table):
"""
Return a map between index and column for a given table
"""
table_index = {} table_index = {}
method = getattr(self, self.sql_catalog_index, '') method = getattr(self, self.sql_catalog_index, '')
if method in ('', None): if method in ('', None):
...@@ -1831,7 +1831,13 @@ class Catalog(Folder, ...@@ -1831,7 +1831,13 @@ class Catalog(Folder,
table_index[line.KEY_NAME].append(line.COLUMN_NAME) table_index[line.KEY_NAME].append(line.COLUMN_NAME)
else: else:
table_index[line.KEY_NAME] = [line.COLUMN_NAME,] table_index[line.KEY_NAME] = [line.COLUMN_NAME,]
return table_index.copy() return table_index
def getTableIndex(self, table):
"""
Return a map between index and column for a given table
"""
return self._getTableIndex(table).copy()
@profiler_decorator @profiler_decorator
def isValidColumn(self, column_id): def isValidColumn(self, column_id):
......
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