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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c805e0578de8d26ad5b1ab75e0a43e11fa87cfa7742f872405598d26194537d0
4
- data.tar.gz: 26cc5f52280ef8fe6fd031f7aceb0fc696765259f81ce472353d127a9b216107
3
+ metadata.gz: abb973879fc47b098296d28aff0023d3c3a734acff63da3f59cde4c3129ea08d
4
+ data.tar.gz: 6283be1e1037e203a1c842e8371f6a0b4eef1b506c2ef1a7b260a6ffe89aa9ac
5
5
  SHA512:
6
- metadata.gz: 3b420b642d7e64839037eeb9ba7204ff654ae536e097cbe9e02c510753d98cb06f4e6d811975bd400f6b8b28d7e29dfa7dbcd5aeee34bbec42133fc6c3c5e166
7
- data.tar.gz: f505f8ec94c6bf04c977eddedaffdcd5dadb6825e49e09b9f8f37652bfc6846831c39b63bac913a9e70aea4cc50400a2c8b6d761fae9c415ae12e1f4f3f8fddf
6
+ metadata.gz: 2ef6234f201e71933e61fa965fa718fad2c4db88c70e9ef724b3de754105b519b45ffc415fe0df72a2c8dfb1e4c9f29fe9b0ae304a0c6658a6aa7ca9944ecbb0
7
+ data.tar.gz: 67a511de5b14d5b28265a273bf0a0cb706027c49da8d1885328eab9cbc6c8443ea69aacadb77dc2eba8a5159864b8f05be1ccdbd9586f97b2ae993128d39d1e9
@@ -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 Hash === args && args.length > 0
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
- instance_eval <<~RUBY
46
- def materialize(pg_result, index)
47
- r = self.new
48
- #{col=-1; fields.map{|f| "r.#{f} = pg_result.getvalue(index, #{col+=1})"}.join("; ")}
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
@@ -1,3 +1,3 @@
1
1
  module MiniSql
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  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: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron