Fix Person creation issues and enhance V3 CRUD robustness.

- Added Pydantic validators to Person_Base to handle null values for given_name and allow_auth_key, ensuring database NOT NULL constraints are met.
- Updated api_crud_v3.py (POST and PATCH) to filter out virtual *_id_random fields from data payloads before database operations to prevent "Unknown column" errors.
- Updated GEMINI.md with session progress.
This commit is contained in:
Scott Idem
2026-01-09 14:30:45 -05:00
parent d32304c50a
commit 29b4d5ae4b
3 changed files with 34 additions and 3 deletions

View File

@@ -427,6 +427,11 @@ async def post_obj(
data_to_insert = validated_obj.dict(exclude_unset=True)
# Filter out virtual _id_random fields (e.g., account_id_random) that are not in the DB table
keys_to_remove = [k for k in data_to_insert.keys() if k.endswith('_id_random') and k != 'id_random']
for k in keys_to_remove:
del data_to_insert[k]
if sql_insert_result := sql_insert(data=data_to_insert, table_name=table_name_insert):
new_obj_id = sql_insert_result
new_obj_id_random = get_id_random(record_id=new_obj_id, table_name=obj_name)
@@ -479,6 +484,11 @@ async def patch_obj(
else:
return mk_resp(data=False, status_code=404, response=response, status_message=f"Object with ID '{obj_id}' not found in database.")
# Filter out virtual _id_random fields (e.g., account_id_random) that are not in the DB table
keys_to_remove = [k for k in obj_data.keys() if k.endswith('_id_random') and k != 'id_random']
for k in keys_to_remove:
del obj_data[k]
if sql_update(data=obj_data, table_name=table_name_update, record_id=record_id):
if return_obj:
if sql_select_result := sql_select(table_name=table_name_select, record_id=record_id):