Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
please see PR code https://github.com/discourse/mini_sql/pull/13/files
I added info to readme and benchmarks
I really like the design here and feel it keeps with the design of mini_racer and performance goals.
Mixed on just supporting
@davidtaylorhq what do you think about this change?
module MiniSql module Postgres class Connection < MiniSql::Connection def query2(sql, *params, decorator: nil) [sql, params, decorator] end def query_decorator(decorator, sql, *params) [sql, params, decorator] end end end end Benchmark.ips do |r| r.stats = :bootstrap r.confidence = 99 r.report('query2') do |n| while n > 0 $mini_sql.query2('select id, title from topics order by id limit 1000', decorator: TopicDecorator) n -= 1 end end r.report('query_decorator') do |n| while n > 0 $mini_sql.query_decorator(TopicDecorator, 'select id, title from topics order by id limit 1000') n -= 1 end end r.compare! end
also I think that
$mini_sql.query_decorator(TopicDecorator, <<~SQL, param1: 'val1', param2: 'val2', param3: 'val3', param4: 'val4') big sql SQL $mini_sql.query(<<~SQL, param1: 'val1', param2: 'val2', param3: 'val3', param4: 'val4', decorator: TopicDecorator) big sql SQL