digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
255 stars 8 forks source link

Add `#batch_query` methods that return aggregate query results #53

Closed noteflakes closed 10 months ago

noteflakes commented 11 months ago

This in order to allow batch executing insert ... returning ... queries.

db.batch_query('insert into foo values (?) returning *', 1..3)
#=>[ {bar: 1}, {bar: 2}, {bar: 3}]

db.batch_query_ary('insert into foo values (?) returning *', 1..3)
#=> [ [1], [2], [3] ]

db.batch_query_single_column('insert into foo values (?) returning bar', 1..3)
#=> [1, 2, 3]

# Can also used with a block:
db.batch_query_single_column('insert into foo values (?) returning bar', 1..3) do |bar|
  p bar
end
# 1
# 2
# 3
#=> db
noteflakes commented 10 months ago

Implement in #61 .