Class: ROM::SQL::Commands::Create
- Inherits:
-
Commands::Create
- Object
- Commands::Create
- ROM::SQL::Commands::Create
- Defined in:
- lib/rom/sql/commands.rb
Instance Method Summary collapse
Instance Method Details
#execute(tuples) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rom/sql/commands.rb', line 11 def execute(tuples) pks = Array([tuples]).flatten.map do |tuple| attributes = input[tuple] validator.call(attributes) relation.insert(attributes.to_h) end relation.where(relation.model.primary_key => pks) rescue *ERRORS => e raise ConstraintError, e. end |