digital-fabric / extralite

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

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

Closed noteflakes closed 5 months ago

noteflakes commented 6 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 5 months ago

Implement in #61 .