The continuation of gem should return the identifier of the newly inserted records , but as others have said:
- return value depends on adapter
Also I would like to add ...
- not sure what to return when encountering a composite primary key
You can get around this by specifying a continuation that should be returned using the #returning method.
For instance:
DB[:posts].returning(:id).insert(category_id: 5, id: 1, ...)
will return [{id: 1}]
and
DB[:posts].returning(:id, :category_id).insert(category_id: 5, id: 1, ...)
will return [{id: 1, category_id: 5}]
source share