json2sql 1.0.15 → 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 +8 -6
- 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
|
|
@@ -115,7 +115,7 @@ module Json2sql
|
|
|
115
115
|
|
|
116
116
|
# Filters children/parents relations in :allow mode.
|
|
117
117
|
# Only relations present as keys in config[relation] pass through.
|
|
118
|
-
# 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.
|
|
119
119
|
# No-op in :deny mode.
|
|
120
120
|
|
|
121
121
|
def filter_relations(params, config, relation)
|
|
@@ -128,15 +128,14 @@ module Json2sql
|
|
|
128
128
|
|
|
129
129
|
config_tables = config[relation]
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
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) } : {}
|
|
134
132
|
end
|
|
135
133
|
|
|
136
134
|
# Filters "columns" using mode (:allow or :deny).
|
|
137
135
|
# Handles Array (SELECT) and Hash (INSERT/UPDATE) column formats.
|
|
138
136
|
# Hash entries (function columns) always pass through in :allow mode.
|
|
139
|
-
# 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.
|
|
140
139
|
|
|
141
140
|
def filter_columns(params, config)
|
|
142
141
|
|
|
@@ -146,7 +145,10 @@ module Json2sql
|
|
|
146
145
|
|
|
147
146
|
list = config["columns"]
|
|
148
147
|
|
|
149
|
-
|
|
148
|
+
if !list.is_a?(Array)
|
|
149
|
+
params["columns"] = columns.is_a?(Array) ? [] : {} if @mode == :allow
|
|
150
|
+
return
|
|
151
|
+
end
|
|
150
152
|
|
|
151
153
|
params["columns"] = if @mode == :deny
|
|
152
154
|
|
data/lib/json2sql/version.rb
CHANGED