mini_sql 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/mini_sql/mysql/connection.rb +3 -3
- data/lib/mini_sql/mysql/prepared_connection.rb +5 -2
- data/lib/mini_sql/postgres/connection.rb +5 -5
- data/lib/mini_sql/postgres/prepared_connection.rb +5 -2
- data/lib/mini_sql/sqlite/connection.rb +1 -1
- data/lib/mini_sql/sqlite/prepared_connection.rb +5 -2
- data/lib/mini_sql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d46350915a655a1692de9b775f879609f83ff068bf9b62be6498672b223ee03
|
4
|
+
data.tar.gz: 192596f2834a676f123afcfb969a32267b311fe20318527ae13b92dd95efc757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9820695fc27ced3ce61b2a131201c6bb954eca9919cd49f29f2877ebccbbd33ef8e36b4a0284d0a04fde9ec92c1f33bbfe75780515cdec26bdf9493e676b631d
|
7
|
+
data.tar.gz: d2ba6adbdf07a1a3fb11192ad949c8f632035a357d792eb895350ee3af30f7977d6b8e64d5df59b1338e9349d213e4472099593c6296e39203fac7ee8147da7d
|
data/CHANGELOG
CHANGED
@@ -13,7 +13,7 @@ module MiniSql
|
|
13
13
|
|
14
14
|
def prepared(condition = true)
|
15
15
|
if condition
|
16
|
-
@prepared ||= PreparedConnection.new(self
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
-
|
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 ||=
|
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
|
-
|
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
|
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)
|
@@ -6,10 +6,9 @@ module MiniSql
|
|
6
6
|
|
7
7
|
attr_reader :unprepared
|
8
8
|
|
9
|
-
def initialize(unprepared_connection
|
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)
|
data/lib/mini_sql/version.rb
CHANGED