mini_sql 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mini_sql/builder.rb +2 -2
- data/lib/mini_sql/deserializer_cache.rb +14 -4
- 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: abb973879fc47b098296d28aff0023d3c3a734acff63da3f59cde4c3129ea08d
|
4
|
+
data.tar.gz: 6283be1e1037e203a1c842e8371f6a0b4eef1b506c2ef1a7b260a6ffe89aa9ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef6234f201e71933e61fa965fa718fad2c4db88c70e9ef724b3de754105b519b45ffc415fe0df72a2c8dfb1e4c9f29fe9b0ae304a0c6658a6aa7ca9944ecbb0
|
7
|
+
data.tar.gz: 67a511de5b14d5b28265a273bf0a0cb706027c49da8d1885328eab9cbc6c8443ea69aacadb77dc2eba8a5159864b8f05be1ccdbd9586f97b2ae993128d39d1e9
|
data/lib/mini_sql/builder.rb
CHANGED
@@ -11,9 +11,9 @@ class MiniSql::Builder
|
|
11
11
|
|
12
12
|
[:set, :where2, :where, :order_by, :limit, :left_join, :join, :offset, :select].each do |k|
|
13
13
|
define_method k do |data, *args|
|
14
|
-
if
|
14
|
+
if args && (args.length == 1) && (Hash === args[0])
|
15
15
|
@args ||= {}
|
16
|
-
@args.merge!(args)
|
16
|
+
@args.merge!(args[0])
|
17
17
|
elsif args && args.length > 0
|
18
18
|
data = @connection.param_encoder.encode(data, *args)
|
19
19
|
end
|
@@ -40,14 +40,24 @@ module MiniSql
|
|
40
40
|
|
41
41
|
Class.new do
|
42
42
|
attr_accessor(*fields)
|
43
|
+
|
44
|
+
# AM serializer support
|
43
45
|
alias :read_attribute_for_serialization :send
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
def to_h
|
48
|
+
r = {}
|
49
|
+
instance_variables.each do |f|
|
50
|
+
r[f.to_s.sub('@','').to_sym] = instance_variable_get(f)
|
51
|
+
end
|
49
52
|
r
|
50
53
|
end
|
54
|
+
|
55
|
+
instance_eval <<~RUBY
|
56
|
+
def materialize(pg_result, index)
|
57
|
+
r = self.new
|
58
|
+
#{col=-1; fields.map{|f| "r.#{f} = pg_result.getvalue(index, #{col+=1})"}.join("; ")}
|
59
|
+
r
|
60
|
+
end
|
51
61
|
RUBY
|
52
62
|
end
|
53
63
|
end
|
data/lib/mini_sql/version.rb
CHANGED