Commit 2786c72b authored by Vincent Pelletier's avatar Vincent Pelletier

When query_table is given a false value, do not expand related keys.

  Also, since columns are not mapped to any table when query_table is set to a false value, this means that catalog passes column names through. The purppose of using catalog over rendering "by hand" the where-expression is that it will use search keys (keyword key, fulltext key, ...) to guess desired operator.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25060 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 860bb280
...@@ -1924,38 +1924,40 @@ class Catalog(Folder, ...@@ -1924,38 +1924,40 @@ class Catalog(Folder,
kw[key] = REQUEST[key] kw[key] = REQUEST[key]
def getNewKeyAndUpdateVariables(key): def getNewKeyAndUpdateVariables(key):
key_is_acceptable = key in acceptable_key_map # Only calculate once
key_is_related = key in related_keys
new_key = None new_key = None
if key_is_acceptable or key_is_related: if query_table:
if key_is_related: # relation system has priority (ex. security_uid) key_is_acceptable = key in acceptable_key_map # Only calculate once
# We must rename the key key_is_related = key in related_keys
method_id = related_method[key] if key_is_acceptable or key_is_related:
table_list = related_table_list[key] if key_is_related: # relation system has priority (ex. security_uid)
if not related_methods.has_key((table_list,method_id)): # We must rename the key
related_methods[(table_list,method_id)] = 1 method_id = related_method[key]
# Prepend renamed table name table_list = related_table_list[key]
new_key = "%s.%s" % (related_table_map[(table_list,method_id)][-1][-1], if not related_methods.has_key((table_list,method_id)):
related_column[key]) related_methods[(table_list,method_id)] = 1
elif key_is_acceptable: # Prepend renamed table name
if key.find('.') < 0: new_key = "%s.%s" % (related_table_map[(table_list,method_id)][-1][-1],
# if the key is only used by one table, just append its name related_column[key])
if len(acceptable_key_map[key]) == 1 : elif key_is_acceptable:
new_key = '%s.%s' % (acceptable_key_map[key][0], key) if key.find('.') < 0:
# query_table specifies what table name should be used by default # if the key is only used by one table, just append its name
elif query_table and \ if len(acceptable_key_map[key]) == 1 :
'%s.%s' % (query_table, key) in acceptable_key_map: new_key = '%s.%s' % (acceptable_key_map[key][0], key)
new_key = '%s.%s' % (query_table, key) # query_table specifies what table name should be used by default
elif key == 'uid': elif '%s.%s' % (query_table, key) in acceptable_key_map:
# uid is always ambiguous so we can only change it here new_key = '%s.%s' % (query_table, key)
new_key = 'catalog.uid' elif key == 'uid':
# uid is always ambiguous so we can only change it here
new_key = 'catalog.uid'
else:
LOG('SQLCatalog', WARNING, 'buildSQLQuery this key is too ambiguous : %s' % key)
else: else:
LOG('SQLCatalog', WARNING, 'buildSQLQuery this key is too ambiguous : %s' % key) new_key = key
else: if new_key is not None:
new_key = key # Add table to table dict, we use catalog by default
if new_key is not None: from_table_dict[acceptable_key_map[new_key][0]] = acceptable_key_map[new_key][0]
# Add table to table dict, we use catalog by default else:
from_table_dict[acceptable_key_map[new_key][0]] = acceptable_key_map[new_key][0] new_key = key
key_alias_dict[key] = new_key key_alias_dict[key] = new_key
return new_key return new_key
......
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