mini_sql 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49e28eb6f0b011fa819621155a5f4507140035c5c4386d8dbcd297ea81981ad8
4
- data.tar.gz: 0dd3f883623ab47c530ebdce212f32cd02a2eb76dd9b51a27e165425b1dad974
3
+ metadata.gz: bbfef3c29b94c4d0bdbb461b52419644f3b042236f58837a6247a84546034e26
4
+ data.tar.gz: 52b175f5f3c712f891f61fe47618584c4279e0bd9f4a0496fb545bd3574eb8ba
5
5
  SHA512:
6
- metadata.gz: e52ffd9133bd63060e6f5f7373958196ba56e5e1ffa38b910fe1119154f06bb076634aa18b5cad3c13045fcbf5cc6990f7966db258aea455dda62a67f2d608ee
7
- data.tar.gz: a3d8370bd15bf01f150c58521da264bddfd4e766d370fa776d052d22a0b484513e2b8fa8b1588c352b4c87c023876b65cfa117655fc0c5390b5da9ea64f5751f
6
+ metadata.gz: 00a003b8bdc6bdf623ad10d3702b3851b0c5bdbc5c1d82c76aa40c5dd797ef11d4bcb153d85cf323d451403d87fb90d0b12c43da3df84a5c49aa84b1d8c8c570
7
+ data.tar.gz: 11fd1b56b47b9ef11d452e1c8eca322ec35ac054a78195fe30bfbeacd1858e67092cc96248f724cab0c9d4b795b0bcdd8e75a3c678bce8ba9787973f47f33439
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 2022-03-07 - 1.4.0
2
+
3
+ - PERF: Optimize multiple use param in prepared postgres sql
4
+
1
5
  2022-02-02 - 1.3.0
2
6
 
3
7
  - FEATURE: Add ActiveRecordPostgres connection
@@ -6,6 +6,33 @@ module MiniSql
6
6
  module Postgres
7
7
  class PreparedBinds < ::MiniSql::Abstract::PreparedBinds
8
8
 
9
+ def bind_hash(sql, hash)
10
+ sql = sql.dup
11
+ binds = []
12
+ bind_names = []
13
+ i = 0
14
+
15
+ hash.each do |k, v|
16
+ bind_outputs =
17
+ array_wrap(v).map { |vv|
18
+ binds << vv
19
+ bind_names << [BindName.new(k)]
20
+ bind_output(i += 1)
21
+ }.join(', ')
22
+
23
+ sql.gsub!(":#{k}") do
24
+ # ignore ::int and stuff like that
25
+ # $` is previous to match
26
+ if $` && $`[-1] != ":"
27
+ bind_outputs
28
+ else
29
+ ":#{k}"
30
+ end
31
+ end
32
+ end
33
+ [sql, binds, bind_names]
34
+ end
35
+
9
36
  def bind_output(i)
10
37
  "$#{i}"
11
38
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MiniSql
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler