querier 0.4.0 → 0.4.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/querier.rb +34 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d97150ee77685d381ebb876ae14ff305c3d69af0d64acc7b37340c9aa43581
4
- data.tar.gz: 22d2b0f0605663a12105c8e4e98447fa8fbe3106f606d05b6fc7dea740e7a725
3
+ metadata.gz: 40c24ee7c142f7bf047c967cdbee1e703a7c41ee6aafda911c36e02008642b6f
4
+ data.tar.gz: d4203cdcc429107b363c917ec493dc30c25e730fcef9cbf7a76f9653e533eb36
5
5
  SHA512:
6
- metadata.gz: eda402af270f074d728d12d9ed2c0df757f44bcdfba4c8053ff06ca8480776de20088128a3a7dd6b428b9f3902ceaa6cc4790e35a81a95d8ffd0570e0c8833cd
7
- data.tar.gz: 85045af2ce676784cf34a338d8dfbfc6cf7d9f10b4392053c7b908e7c80f1ae66986ac64b47ca71a695d7f7bcc4993095a6e91d718a68c0a5cc5c57436f4717b
6
+ metadata.gz: 5400b60fbc5e6c9bcaec3cc844ed919f855557e8e76b78c6eede62da5700a040beeac4b2fae880fd92a5bdf068cf5052e255d5182306ba411d8fd8b3e6a925ca
7
+ data.tar.gz: f7304d4dfaf39b60845e1931e2040f4bafa84a745158d4ea03f08459bf48e0f4eec72a28b255c2d6537c4e31da1279fd91c2240f875eaba03c11172ba1c6b1c2
data/lib/querier.rb CHANGED
@@ -23,25 +23,50 @@ class Querier
23
23
  @active_record_class.connection.execute(@query)
24
24
  end
25
25
 
26
+ def exec_query
27
+ decorate_dataset_format(@active_record_class.connection.exec_query(@query))
28
+ end
29
+
26
30
  def select_all
27
- result = @active_record_class.connection.select_all(@query)
31
+ decorate_dataset_format(@active_record_class.connection.select_all(@query))
32
+ end
33
+
34
+ def select_one
35
+ @active_record_class.connection.select_one(@query)
36
+ end
37
+
38
+ def select_values
39
+ @active_record_class.connection.select_values(@query)
40
+ end
41
+
42
+ def select_rows
43
+ @active_record_class.connection.select_rows(@query)
44
+ end
45
+
46
+ def select_value
47
+ @active_record_class.connection.select_value(@query)
48
+ end
49
+
50
+ private
28
51
 
29
- def result.as_hash
30
- map(&:symbolize_keys!)
52
+ def decorate_dataset_format(dataset)
53
+ def dataset.as_hash
54
+ map(&:symbolize_keys)
31
55
  end
32
56
 
33
- def result.as_struct
57
+ def dataset.as_struct
34
58
  map { |record| OpenStruct.new(record) }
35
59
  end
36
60
 
37
- result
61
+ dataset
38
62
  end
39
63
 
40
- private
41
-
42
64
  def get_param_value(raw_query_param:, quotefy_param: true)
43
- # where's String#quote when we need it?
44
- raw_query_param.instance_of?(String) && quotefy_param ? "'#{raw_query_param.to_s}'" : raw_query_param.to_s
65
+ if raw_query_param.instance_of?(String) && quotefy_param
66
+ @active_record_class.connection.quote(raw_query_param.to_s)
67
+ else
68
+ raw_query_param.to_s
69
+ end
45
70
  end
46
71
 
47
72
  def fill_query_params
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: querier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gedean Dias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Active Record queries with variable number of params
14
14
  email: gedean.dias@gmail.com