Sha256: 6a3601a25d246302ae1f775fd449b82bca11e986580db0b471e2e14191dc4206
Contents?: true
Size: 877 Bytes
Versions: 3
Compression:
Stored size: 877 Bytes
Contents
# frozen_string_literal: true require "mini_sql/abstract/prepared_binds" module MiniSql module Postgres class PreparedBinds < ::MiniSql::Abstract::PreparedBinds def bind_hash(sql, hash) sql = sql.dup binds = [] bind_names = [] i = 0 hash.each do |k, v| bind_outputs = array_wrap(v).map { |vv| binds << vv bind_names << [BindName.new(k)] bind_output(i += 1) }.join(', ') sql.gsub!(":#{k}") do # ignore ::int and stuff like that # $` is previous to match if $` && $`[-1] != ":" bind_outputs else ":#{k}" end end end [sql, binds, bind_names] end def bind_output(i) "$#{i}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mini_sql-1.6.0 | lib/mini_sql/postgres/prepared_binds.rb |
mini_sql-1.5.0 | lib/mini_sql/postgres/prepared_binds.rb |
mini_sql-1.4.0 | lib/mini_sql/postgres/prepared_binds.rb |