8000 Return number of inserted/updated records? · Issue #117 · jesjos/active_record_upsert · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Return number of inserted/updated records? #117
Open
@hammady

Description

@hammady

Is it possible to return the number of inserted records (or updated ones) as a result of executing the upsert statement?
For example, when the INSERT succeeds, it could set an instance variable: __inserted: 1. If there was a conflict and there was a ON CONFLICT DO UPDATE, the number of updated records are set: __updated: 1. If there was a WHERE clause in the update which caused the update not to go through the value would be __updated: 0.
I inspected the generated statement and I could see RETURNING *, xmax = 0, so probably the last boolean can indicate insertion count?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0