fix: exclude account_id and virtual fields from archive_content DB writes
- Adds fields_to_exclude_from_db to Archive_Content_Base to prevent SQL errors on non-existent columns. - Updates documentation for V3 Create/Update patterns and the x-ae-ignore-extra-fields header. - Propagates account_id_random to hosted file and media processing methods.
This commit is contained in:
@@ -1323,6 +1323,20 @@ def post_obj_template(
|
||||
table_name_select = obj_type_kv_li[obj_type]['table_name']
|
||||
base_name = obj_type_kv_li[obj_type]['base_name']
|
||||
|
||||
# # Prune any keys that are not actual columns on the target table to avoid
|
||||
# # SQL errors when clients include convenience fields (e.g., account_id)
|
||||
# try:
|
||||
# from app import lib_sql_core
|
||||
# from sqlalchemy import text
|
||||
# with lib_sql_core.engine.connect() as conn:
|
||||
# cols_res = conn.execute(text(f"DESCRIBE `{table_name_insert}`;"))
|
||||
# cols = [r[0] for r in cols_res.fetchall()]
|
||||
# # keep only keys that match real columns (always allow id_random)
|
||||
# obj_data = {k: v for k, v in obj_data.items() if k in cols or k == 'id_random'}
|
||||
# except Exception as _:
|
||||
# # If DESCRIBE fails for any reason, fall back to original obj_data
|
||||
# log.debug(f"Could not inspect table columns for {table_name_insert}; proceeding without pruning.")
|
||||
|
||||
if sql_insert_result := sql_insert(table_name=table_name_insert, data=obj_data, id_random_length=id_random_length):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(sql_insert_result)
|
||||
|
||||
@@ -276,6 +276,7 @@ async def convert_file(
|
||||
link_to_type = link_to_type,
|
||||
link_to_id = lid_int,
|
||||
account_id = commons.x_account_id,
|
||||
account_id_random = commons.x_account_id_random,
|
||||
filename_no_ext = filename_no_ext,
|
||||
to_type = to_type
|
||||
)
|
||||
@@ -306,6 +307,7 @@ async def clip_video(
|
||||
start_time = start_time,
|
||||
end_time = end_time,
|
||||
account_id = commons.x_account_id,
|
||||
account_id_random = commons.x_account_id_random,
|
||||
link_to_type = link_to_type,
|
||||
link_to_id = lid_int,
|
||||
filename_no_ext = filename_no_ext,
|
||||
|
||||
Reference in New Issue
Block a user