Skip to content

Conversation

Badlybear
Copy link

main.py:
Fixed Postgres error on file_counts updates
Replaced two assignments to the same column in one UPDATE with a single assignment (nested jsonb_set) in both single and batch endpoints.
This removes ERROR: multiple assignments to same column "file_counts" and keeps counters correct.
Made SQL result keys stable (avoid KeyError: '"id"')
Added explicit column aliases (AS id, AS content, …) in every SELECT and RETURNING.
The code now reads row["id"], row["content"], etc., reliably.
Made timestamps consistent and driver-agnostic
Converted DB timestamps to epoch seconds in SQL using EXTRACT(EPOCH FROM ...) AS ..._ts.
Removed Python .timestamp() calls (which failed when the driver returned strings).
All responses now use integer epoch fields (created_at, expires_at, last_active_at) safely.
Kept behavior but hardened pagination & limits
limit is clamped to a maximum (100).
has_more logic preserved; first_id/last_id populated from the page slice.
Safer vector search & filtering
Query embedding is computed once, cast to ::vector and used with <=>.
Metadata filters use parameterized jsonb access (metadata->>$key = $value).
Batch insert is fully parameterized
Values list constructed with positional parameters; no string interpolation of data.
Returns aliased columns for uniform response building.
Error handling & responses unchanged for API surface
Models and endpoints didn’t change shape; only internal query/row handling & stability.

Dockerfile-airgapped:
Make the image run in closed networks by baking Prisma engines into the image and pre-generating the Prisma Python client during the online build stage.
Avoid any runtime downloads; Prisma loads binaries from a local cache directory.
Keep the runtime image minimal and network-independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant