Skip to content

CRUD endpoint POST response is a single-item list instead of an object - #338

Open
juneja-varun wants to merge 1 commit into
piccolo-orm:masterfrom
juneja-varun:fix/post-response-shape
Open

juneja-varun wants to merge 1 commit into
piccolo-orm:masterfrom
juneja-varun:fix/post-response-shape

Conversation

@juneja-varun

@juneja-varun juneja-varun commented Sep 3, 2026

Copy link
Copy Markdown

Closes #211.

I POST to a PiccoloCRUD endpoint to create a resource and expect to read the new id off the parsed response (response.json()["id"]), but the body comes back as a single-item list instead - [{"id": 4}] - so every client has to unwrap it first.

row.save().run() on a new row returns a list from insert(self).returning(pk_column) even for a single row, and that list was JSON-dumped directly. The BaseUser branch two lines above already unwraps its single item correctly, so this brings the general-table branch in line with that existing pattern.

Added a regression test confirming the response is a dict with the correct id, and fixed one existing test that had encoded the buggy list shape as its expected value. Worth flagging as a response-shape change - any client currently unwrapping a list would need to read the id directly after this lands, which is the shape the issue (and ModelOut's own schema) already expects.

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.

CRUD Endpoint POST response is a list

1 participant