Skip to content

Commit e5acbd9

Browse files
committed
Use dataset to fetch record after insert
Similarily to what Update command do, use `dataset` to load the tuple after `insert` in Create command. This way it loads "raw" data, without applying read types yet. So when tuples are passed into `finalize` hook, it can properly apply these read types.
1 parent 577b9b6 commit e5acbd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rom/sql/commands/create.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def finalize(tuples, *)
4646
# @api private
4747
def insert(tuples)
4848
pks = tuples.map { |tuple| relation.insert(tuple) }
49-
relation.where(relation.primary_key => pks).to_a
49+
relation.dataset.where(relation.primary_key => pks).to_a
5050
end
5151

5252
# Executes multi_insert statement and returns inserted tuples
5353
#
5454
# @api private
5555
def multi_insert(tuples)
5656
pks = relation.multi_insert(tuples, return: :primary_key)
57-
relation.where(relation.primary_key => pks).to_a
57+
relation.dataset.where(relation.primary_key => pks).to_a
5858
end
5959

6060
# Yields tuples for insertion or return an enumerator

0 commit comments

Comments
 (0)