Skip to content

Feature Request: Support select() for Resource Embedding on Write Operations #1271

@coroluca

Description

@coroluca

The PostgREST API supports embedding related resources on write operations by using the select query parameter.

Currently, postgrest-py provides the .select() method for read operations, but there isn't a direct way to apply it to insert(), update(), or delete calls to achieve this embedding.
Would it be possible to extend the builder pattern to allow .select() to be chained after insert(), update() and delete() methods?

Currently, I can achieve this by manually manipulating the request parameters after building the initial insert/update request. This works but is not ideal as it relies on internal implementation details.

My current workaround (with postgrest-py v2.20.0):

values = { "title": "127 hours", "director_id": "40", ... }

req = client.from_("films").insert(values, returning=ReturnMethod.representation)

# Manually add the 'select' parameter before execution
req.params = req.params.add("select", "title,year,director:directors(first_name,last_name)")

response = await req.execute()

Thank you for considering it

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpostgrestIssues related to postgrest-pypythonPull requests that update Python code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions