ID Vision Phase 2: Standardize Page, Post, Person, Organization, and Hosted File objects
This commit is contained in:
@@ -205,14 +205,35 @@ def sql_search_qry_part(
|
||||
def process_filter(f) -> tuple[str, dict]:
|
||||
# --- ID VISION MAPPING ---
|
||||
# If the frontend uses clean names (id, account_id),
|
||||
# map them to the database columns (id_random, account_id_random).
|
||||
# map them to the database columns (id_random, account_id_random)
|
||||
# ONLY if those columns actually exist in this table/view.
|
||||
target_field = f.field
|
||||
vision_fields = ['id', 'account_id', 'site_id', 'person_id', 'user_id', 'journal_id', 'journal_entry_id']
|
||||
vision_fields = [
|
||||
'id', 'account_id', 'site_id', 'person_id', 'user_id',
|
||||
'journal_id', 'journal_entry_id', 'page_id', 'post_id',
|
||||
'post_comment_id', 'organization_id', 'address_id', 'hosted_file_id'
|
||||
]
|
||||
|
||||
if target_field in vision_fields:
|
||||
if target_field == 'id': target_field = 'id_random'
|
||||
else: target_field = f"{target_field}_random"
|
||||
print(f"Search Trace: Mapping filter field '{f.field}' -> '{target_field}'", flush=True)
|
||||
candidate_field = 'id_random' if target_field == 'id' else f"{target_field}_random"
|
||||
|
||||
# Schema Check: Verify if the random version exists in the current table/view
|
||||
use_random = False
|
||||
if table_name:
|
||||
try:
|
||||
lib_sql_core.db.execute(text(f"SELECT `{candidate_field}` FROM `{table_name}` LIMIT 0"))
|
||||
use_random = True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if use_random:
|
||||
target_field = candidate_field
|
||||
print(f"Search Trace: Mapping filter field '{f.field}' -> '{target_field}'", flush=True)
|
||||
else:
|
||||
# If random doesn't exist, we must stick to the integer column
|
||||
# but we'll need to resolve the string value to an integer elsewhere
|
||||
# or rely on the user providing an integer for now.
|
||||
pass
|
||||
|
||||
if searchable_fields is not None and target_field not in searchable_fields:
|
||||
# Fallback check for original field just in case
|
||||
|
||||
Reference in New Issue
Block a user