Description
Hello. I wanted to take advantage of RETURNING
to save a round-trip to the database for an area that is particularly costly. However activerecord-import which we're using (just bumped to latest) in the Rails app (Rails 5.x) seems to take over the import
method that Active Record provides that would let me specify a returning
clause which I initially intended to use, then stumbled into activerecord-import.
-
Is there a way around activerecord-import definition of
import
of I want to try the Active Record one? Am I missing something on that? -
The other problem is that I see activerecord-import supports
returning
but I'm only seeing examples with a primary key in past issues for the project. We're using the uuid-oosp extension to generate a UUID. Are non-PK columns supported or different in some way? We have this UUID generation happening as the column default. When I insert one record and query it again I see it there in the DB. I see use activerecord-import to insert a single record in a list, it says it is inserted but the in-memory instance does not have the value set, it's not in the returning results, and if I query again I see the column appears null.
e.g. Successful insert of single row where we have external_id
as a UUID non-PK column. But the results are a single nil item and I expected it to be the value for external_id
.
My::Model.import([instance], returning: :external_id)
=> #<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1, ids=[1], results=[nil]>
Activity