rom icon indicating copy to clipboard operation
rom copied to clipboard

Creating an array of relations only returns first saved element

Open mlk5060 opened this issue 4 years ago • 2 comments

Describe the bug

After following the repository quick start guide, specifically the create sub-section, I attempted to pass an array of hashes to the exposed create method on the repository. All array elements were saved to the datasource, but only the first saved element was returned.

To Reproduce

  1. Create a new class that inherits from ROM::Repository
  2. Add the commands :create macro to this class
  3. Attempt to save an array of hashes that represent the relation which the ROM::Repository defined in step 1 handles.
  4. Inspect the underlying datasource and return value of create

Expected behavior

Providing that no elements in the input array violate the underlying datasources constraints, all input array elements should be saved in the underlying datasource, and the return value of create should be an array whose size is equal to the input array, and contain representations of each tuple saved in the underlying datasource

Your environment

  • Affects my production application: NO
  • Ruby version: 2.6.3
  • OS: Ubuntu 16.04/18.04
  • Gemfile:
source "https://rubygems.org"

gem "rake"

# Web framework
gem "dry-system", "~> 0.9"
gem "dry-web", "~> 0.7"
gem "dry-web-roda", "~> 0.11"
gem "puma"
gem "rack_csrf"

gem "rack", ">= 2.0"

# Database persistence
gem "pg"
gem "rom", "~> 5.1"
gem "rom-sql", "~> 3.0.1"

# Application dependencies
gem "dry-matcher", "~> 0.8"
gem "dry-monads", "~> 1.3.0"
gem "dry-struct", "~> 1.0"
gem "dry-transaction", "~> 0.13"
gem "dry-types", "~> 1"
gem "dry-validation", "~> 1.2.1"
gem "dry-view", "~> 0.7"
gem "slim"

group :development, :test do
  gem "pry-byebug", platform: :mri
end

group :development do
  gem "rerun"
end

group :test do
  gem "capybara"
  gem "capybara-screenshot"
  gem "database_cleaner"
  gem "poltergeist"
  gem "rspec"
  gem "rom-factory", "~> 0.5"
end

mlk5060 avatar Aug 06 '19 20:08 mlk5060

For the record, this is happening because the underlying changeset command is configured using result: :one option

solnic avatar Jan 02 '20 15:01 solnic

Thanks for the clarification @solnic!

mlk5060 avatar Jan 03 '20 22:01 mlk5060