Skip to content

Store result ids on ImportResult (postgres only)#191

Closed
saulm wants to merge 2 commits intoactiveadmin-plugins:masterfrom
polyglot-solutions:master
Closed

Store result ids on ImportResult (postgres only)#191
saulm wants to merge 2 commits intoactiveadmin-plugins:masterfrom
polyglot-solutions:master

Conversation

@saulm
Copy link
Copy Markdown

@saulm saulm commented May 13, 2021

I was looking for a solution to #179

Luckily I'm using postgres, and activerecord-import stores the ids for postgres: https://github.com/zdennis/activerecord-import#return-info

I understand this is not the ideal solution for everyone, but it's consistent with the behavior of the underlying base library.

Let me know if this is something you would like to add or if you need any other changes.

@coveralls
Copy link
Copy Markdown

coveralls commented May 13, 2021

Coverage Status

Coverage decreased (-0.006%) to 97.98% when pulling 54fb15b on polyglot-solutions:master into 1c7601f on activeadmin-plugins:master.

Fivell added a commit that referenced this pull request Apr 8, 2026
Adds a :result_class option to active_admin_import so users can plug in
their own ImportResult subclass to collect adapter-specific data (like
inserted ids) without forcing the gem to take on cross-adapter quirks.

The DSL action block now receives result, options via instance_exec
(matching DEFAULT_RESULT_PROC's signature) so the captured data is
actually reachable from user code. Existing zero-arity blocks are
unaffected since Ruby blocks ignore extra arguments.

A PG-only spec demonstrates the canonical PR #191 use case (capturing
result.ids), which is reliable on PostgreSQL via RETURNING but not on
MySQL/SQLite without extra setup.
@Fivell Fivell closed this Apr 8, 2026
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.

4 participants