Skip to content

Add an API for upserting #252

@dantownsend

Description

@dantownsend

Based on this discussion: #248

We don't currently have an API for upserting.

This would be based around the ON CONFLICT clause you can add to INSERT queries.

https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT

There will probably be two APIs needed. Something for insert queries, and a convenience method for objects queries.

For example:

# For insert
Band.insert(Band(name='Pythonistas')).on_conflict(...).run_sync()

# For objects
Band.objects().upsert(Band.name == 'Pythonistas', {Band.popularity: 5000}).run_sync()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions