mini_sql 1.1.2 → 1.1.3

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: 335047554a8bf88fb9f9c3152d5f7056806ee541667ca47ffdfe678d85d16f2e
4
- data.tar.gz: fa574144f2ca9e8427b5d72292af8fbb67e8e89b799bd2ab550639edd6f0eca0
3
+ metadata.gz: 8d46350915a655a1692de9b775f879609f83ff068bf9b62be6498672b223ee03
4
+ data.tar.gz: 192596f2834a676f123afcfb969a32267b311fe20318527ae13b92dd95efc757
5
5
  SHA512:
6
- metadata.gz: b5b92a31e176d19b2c006dfec04884c295e7e9d6eaf04d5222f777b2e4d012225efb8e46699b9be7ad1cd103e87cc1637096a0bbef6cae0dfec928545e5a2538
7
- data.tar.gz: '0685f098c60980117f0278a0f0887b0bd95f6d06ace0aeeba520dd163a7422b686b7d7f4009e29de97f8b713900b206174d3765903f4b6e28c953cfd174f03c3'
6
+ metadata.gz: 9820695fc27ced3ce61b2a131201c6bb954eca9919cd49f29f2877ebccbbd33ef8e36b4a0284d0a04fde9ec92c1f33bbfe75780515cdec26bdf9493e676b631d
7
+ data.tar.gz: d2ba6adbdf07a1a3fb11192ad949c8f632035a357d792eb895350ee3af30f7977d6b8e64d5df59b1338e9349d213e4472099593c6296e39203fac7ee8147da7d
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 2021-03-22 - 1.1.3
2
+
3
+ - DEV: reduce coupling of internal interfaces and allow or cleaner override of prepared connections
4
+
1
5
  2021-03-22 - 1.1.2
2
6
 
3
7
  - FEATURE: improve compatability with clients overriding raw_connection
@@ -13,7 +13,7 @@ module MiniSql
13
13
 
14
14
  def prepared(condition = true)
15
15
  if condition
16
- @prepared ||= PreparedConnection.new(self, @deserializer_cache)
16
+ @prepared ||= PreparedConnection.new(self)
17
17
  else
18
18
  self
19
19
  end
@@ -39,12 +39,12 @@ module MiniSql
39
39
 
40
40
  def query(sql, *params)
41
41
  result = run(sql, :array, params)
42
- @deserializer_cache.materialize(result)
42
+ deserializer_cache.materialize(result)
43
43
  end
44
44
 
45
45
  def query_decorator(decorator, sql, *params)
46
46
  result = run(sql, :array, params)
47
- @deserializer_cache.materialize(result, decorator)
47
+ deserializer_cache.materialize(result, decorator)
48
48
  end
49
49
 
50
50
  def escape_string(str)
@@ -6,10 +6,9 @@ module MiniSql
6
6
 
7
7
  attr_reader :unprepared
8
8
 
9
- def initialize(unprepared_connection, deserializer_cache)
9
+ def initialize(unprepared_connection)
10
10
  @unprepared = unprepared_connection
11
11
  @raw_connection = unprepared_connection.raw_connection
12
- @deserializer_cache = deserializer_cache
13
12
  @param_encoder = unprepared_connection.param_encoder
14
13
 
15
14
  @prepared_cache = PreparedCache.new(@raw_connection)
@@ -24,6 +23,10 @@ module MiniSql
24
23
  condition ? self : @unprepared
25
24
  end
26
25
 
26
+ def deserializer_cache
27
+ @unprepared.deserializer_cache
28
+ end
29
+
27
30
  private def run(sql, as, params)
28
31
  prepared_sql, binds, _bind_names = @param_binder.bind(sql, *params)
29
32
  statement = @prepared_cache.prepare_statement(prepared_sql)
@@ -3,7 +3,7 @@
3
3
  module MiniSql
4
4
  module Postgres
5
5
  class Connection < MiniSql::Connection
6
- attr_reader :raw_connection, :param_encoder
6
+ attr_reader :raw_connection, :param_encoder, :deserializer_cache
7
7
 
8
8
  def self.default_deserializer_cache
9
9
  @deserializer_cache ||= DeserializerCache.new
@@ -48,7 +48,7 @@ module MiniSql
48
48
 
49
49
  def prepared(condition = true)
50
50
  if condition
51
- @prepared ||= PreparedConnection.new(self, @deserializer_cache)
51
+ @prepared ||= PreparedConnection.new(self)
52
52
  else
53
53
  self
54
54
  end
@@ -98,7 +98,7 @@ module MiniSql
98
98
  def query(sql, *params)
99
99
  result = run(sql, params)
100
100
  result.type_map = type_map
101
- @deserializer_cache.materialize(result)
101
+ deserializer_cache.materialize(result)
102
102
  ensure
103
103
  result.clear if result
104
104
  end
@@ -121,7 +121,7 @@ module MiniSql
121
121
  if result.ntuples == 0
122
122
  # skip, this happens at the end when we get totals
123
123
  else
124
- materializer ||= @deserializer_cache.materializer(result)
124
+ materializer ||= deserializer_cache.materializer(result)
125
125
  result.type_map = type_map
126
126
  i = 0
127
127
  # technically we should only get 1 row here
@@ -172,7 +172,7 @@ module MiniSql
172
172
  def query_decorator(decorator, sql, *params)
173
173
  result = run(sql, params)
174
174
  result.type_map = type_map
175
- @deserializer_cache.materialize(result, decorator)
175
+ deserializer_cache.materialize(result, decorator)
176
176
  ensure
177
177
  result.clear if result
178
178
  end
@@ -6,10 +6,9 @@ module MiniSql
6
6
 
7
7
  attr_reader :unprepared
8
8
 
9
- def initialize(unprepared_connection, deserializer_cache)
9
+ def initialize(unprepared_connection)
10
10
  @unprepared = unprepared_connection
11
11
  @raw_connection = unprepared_connection.raw_connection
12
- @deserializer_cache = deserializer_cache
13
12
  @type_map = unprepared_connection.type_map
14
13
  @param_encoder = unprepared_connection.param_encoder
15
14
 
@@ -25,6 +24,10 @@ module MiniSql
25
24
  condition ? self : @unprepared
26
25
  end
27
26
 
27
+ def deserializer_cache
28
+ @unprepared.deserializer_cache
29
+ end
30
+
28
31
  private def run(sql, params)
29
32
  prepared_sql, binds, _bind_names = @param_binder.bind(sql, *params)
30
33
  prepare_statement_key = @prepared_cache.prepare_statement(prepared_sql)
@@ -13,7 +13,7 @@ module MiniSql
13
13
 
14
14
  def prepared(condition = true)
15
15
  if condition
16
- @prepared ||= PreparedConnection.new(self, @deserializer_cache)
16
+ @prepared ||= PreparedConnection.new(self)
17
17
  else
18
18
  self
19
19
  end
@@ -6,10 +6,9 @@ module MiniSql
6
6
 
7
7
  attr_reader :unprepared
8
8
 
9
- def initialize(unprepared_connection, deserializer_cache)
9
+ def initialize(unprepared_connection)
10
10
  @unprepared = unprepared_connection
11
11
  @raw_connection = unprepared_connection.raw_connection
12
- @deserializer_cache = deserializer_cache
13
12
  @param_encoder = unprepared_connection.param_encoder
14
13
 
15
14
  @prepared_cache = PreparedCache.new(@raw_connection)
@@ -24,6 +23,10 @@ module MiniSql
24
23
  condition ? self : @unprepared
25
24
  end
26
25
 
26
+ def deserializer_cache
27
+ @unprepared.deserializer_cache
28
+ end
29
+
27
30
  private def run(sql, params)
28
31
  prepared_sql, binds, _bind_names = @param_binder.bind(sql, params)
29
32
  statement = @prepared_cache.prepare_statement(prepared_sql)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MiniSql
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron