feat(v3): robust search wildcards, smart status filtering, and fixed ID population
This commit is contained in:
@@ -2034,6 +2034,7 @@ def sql_and_in_dict_li_part(
|
||||
|
||||
# ### BEGIN ### API DB SQL Methods ### sql_enable_part() ###
|
||||
# Updated 2022-01-17
|
||||
# Updated 2026-01-06 to handle missing enable column gracefully.
|
||||
@logger_reset
|
||||
def sql_enable_part(table_name: str, enabled: str) -> bool|dict:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -2043,19 +2044,25 @@ def sql_enable_part(table_name: str, enabled: str) -> bool|dict:
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
log.info(f'Creating partial SQL string for "enabled" check. Enabled: {enabled}')
|
||||
|
||||
if enabled == 'all':
|
||||
return '', None
|
||||
|
||||
# Check if column exists
|
||||
try:
|
||||
db.execute(text(f"SELECT enable FROM `{table_name}` LIMIT 0"))
|
||||
except:
|
||||
log.warning(f"Table/View '{table_name}' does not have an 'enable' column. Skipping filter.")
|
||||
return '', None
|
||||
|
||||
if enabled == 'enabled':
|
||||
# sql = f'AND `person`.enable = :enable'
|
||||
sql = f'AND `{table_name}`.enable = true'
|
||||
enable = True
|
||||
elif enabled == 'disabled':
|
||||
# sql = f'AND `person`.enable = :enable'
|
||||
sql = f'AND `{table_name}`.enable = false'
|
||||
enable = False
|
||||
elif enabled == 'all':
|
||||
sql = ''
|
||||
enable = None
|
||||
|
||||
log.debug(sql)
|
||||
|
||||
return sql, enable
|
||||
else:
|
||||
return False
|
||||
@@ -2064,6 +2071,7 @@ def sql_enable_part(table_name: str, enabled: str) -> bool|dict:
|
||||
|
||||
# ### BEGIN ### API DB SQL Methods ### sql_hidden_part() ###
|
||||
# Updated 2022-01-17
|
||||
# Updated 2026-01-06 to handle missing hide column gracefully.
|
||||
@logger_reset
|
||||
def sql_hidden_part(table_name: str, hidden: str) -> bool|dict:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -2073,17 +2081,25 @@ def sql_hidden_part(table_name: str, hidden: str) -> bool|dict:
|
||||
|
||||
if hidden in ['hidden', 'not_hidden', 'all']:
|
||||
log.info(f'Creating partial SQL string for "hidden" check. Hide: {hidden}')
|
||||
|
||||
if hidden == 'all':
|
||||
return '', None
|
||||
|
||||
# Check if column exists
|
||||
try:
|
||||
db.execute(text(f"SELECT hide FROM `{table_name}` LIMIT 0"))
|
||||
except:
|
||||
log.warning(f"Table/View '{table_name}' does not have a 'hide' column. Skipping filter.")
|
||||
return '', None
|
||||
|
||||
if hidden == 'hidden':
|
||||
sql = f'AND `{table_name}`.hide = true'
|
||||
hide = True
|
||||
elif hidden == 'not_hidden':
|
||||
sql = f'AND (`{table_name}`.hide = false OR `{table_name}`.hide IS NULL)'
|
||||
hide = False
|
||||
elif hidden == 'all':
|
||||
sql = ''
|
||||
hide = None
|
||||
|
||||
log.debug(sql)
|
||||
|
||||
return sql, hide
|
||||
else:
|
||||
return False
|
||||
@@ -2258,4 +2274,4 @@ def sql_search_qry_part(
|
||||
if sql_where:
|
||||
return f"AND ({sql_where})", data
|
||||
return "", {}
|
||||
# ### END ### API DB SQL Methods ### sql_search_qry_part() ###
|
||||
# ### END ### API DB SQL Methods ### sql_search_qry_part() ###
|
||||
Reference in New Issue
Block a user