json2sql 1.0.14 → 1.0.16
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/lib/json2sql/query_policy.rb +13 -7
- data/lib/json2sql/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: 39f16dc1347524e05a3b12ea619883c5cfec2ebf86c13df6954f549fb7f7d934
|
|
4
|
+
data.tar.gz: 6590f96be14c84a510368e25bf875e5223825162b39b1bb3d06f075a6c43a1cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51c4cc95f0a1fb7d529b2366515a0661f48c26cd6c28da176c0e58f7c7bb7f900853e1ce1ffa76c84cfc65797eab3bae6cecac1fd88558fc70c429253005c9d6
|
|
7
|
+
data.tar.gz: 6a6d13a1d6ba250e52fc7a87f5e3f99852d815cbf6bd34b34a170972a478c35df2836cb124959e662b3abd2fb4d8294cb3deb087fd1d80ba2c044eda4416c96b
|
|
@@ -95,7 +95,11 @@ module Json2sql
|
|
|
95
95
|
|
|
96
96
|
def empty_columns?(params)
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
return false unless params.is_a?(Hash)
|
|
99
|
+
|
|
100
|
+
cols = params["columns"]
|
|
101
|
+
|
|
102
|
+
(cols.is_a?(Array) || cols.is_a?(Hash)) && cols.empty?
|
|
99
103
|
end
|
|
100
104
|
|
|
101
105
|
def filter_tables(params, config)
|
|
@@ -111,7 +115,7 @@ module Json2sql
|
|
|
111
115
|
|
|
112
116
|
# Filters children/parents relations in :allow mode.
|
|
113
117
|
# Only relations present as keys in config[relation] pass through.
|
|
114
|
-
# If config[relation] is absent or not a Hash, relations are
|
|
118
|
+
# If config[relation] is absent or not a Hash, all relations are blocked.
|
|
115
119
|
# No-op in :deny mode.
|
|
116
120
|
|
|
117
121
|
def filter_relations(params, config, relation)
|
|
@@ -124,15 +128,14 @@ module Json2sql
|
|
|
124
128
|
|
|
125
129
|
config_tables = config[relation]
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
params[relation] = param_tables.select { |table, _| config_tables.key?(table) }
|
|
131
|
+
params[relation] = config_tables.is_a?(Hash) ? param_tables.select { |table, _| config_tables.key?(table) } : {}
|
|
130
132
|
end
|
|
131
133
|
|
|
132
134
|
# Filters "columns" using mode (:allow or :deny).
|
|
133
135
|
# Handles Array (SELECT) and Hash (INSERT/UPDATE) column formats.
|
|
134
136
|
# Hash entries (function columns) always pass through in :allow mode.
|
|
135
|
-
# If no column list is defined
|
|
137
|
+
# If no column list is defined: in :allow mode all columns are blocked;
|
|
138
|
+
# in :deny mode columns are untouched.
|
|
136
139
|
|
|
137
140
|
def filter_columns(params, config)
|
|
138
141
|
|
|
@@ -142,7 +145,10 @@ module Json2sql
|
|
|
142
145
|
|
|
143
146
|
list = config["columns"]
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
if !list.is_a?(Array)
|
|
149
|
+
params["columns"] = columns.is_a?(Array) ? [] : {} if @mode == :allow
|
|
150
|
+
return
|
|
151
|
+
end
|
|
146
152
|
|
|
147
153
|
params["columns"] = if @mode == :deny
|
|
148
154
|
|
data/lib/json2sql/version.rb
CHANGED