querier 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/querier.rb +34 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40c24ee7c142f7bf047c967cdbee1e703a7c41ee6aafda911c36e02008642b6f
|
4
|
+
data.tar.gz: d4203cdcc429107b363c917ec493dc30c25e730fcef9cbf7a76f9653e533eb36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
30
|
-
|
52
|
+
def decorate_dataset_format(dataset)
|
53
|
+
def dataset.as_hash
|
54
|
+
map(&:symbolize_keys)
|
31
55
|
end
|
32
56
|
|
33
|
-
def
|
57
|
+
def dataset.as_struct
|
34
58
|
map { |record| OpenStruct.new(record) }
|
35
59
|
end
|
36
60
|
|
37
|
-
|
61
|
+
dataset
|
38
62
|
end
|
39
63
|
|
40
|
-
private
|
41
|
-
|
42
64
|
def get_param_value(raw_query_param:, quotefy_param: true)
|
43
|
-
|
44
|
-
|
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.
|
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-
|
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
|