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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7388641e5f74990b482a145d6d096ae5612ebb2b8f8def9761c73d193b56c492
4
- data.tar.gz: 82fa2ae894923ca9d983b7d082bdd4b33fdab7cfb23f96ba3b8c3ab93052e04a
3
+ metadata.gz: 39f16dc1347524e05a3b12ea619883c5cfec2ebf86c13df6954f549fb7f7d934
4
+ data.tar.gz: 6590f96be14c84a510368e25bf875e5223825162b39b1bb3d06f075a6c43a1cc
5
5
  SHA512:
6
- metadata.gz: e109f0025272b5f8387b6d7f457cd0cd59d3271788b160bd7612f0130abf792d46cab329ead1474e8a201f7481a40f449a66d86f5db759c147eda3447411ffc6
7
- data.tar.gz: ff26c02113459a4f8000ab6a59ab7013a1e22546d05fc901359e5b663de57ffc203b90a73c7288d1d737ace6e3385831199249502c24965715be7c8a27712ec1
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
- params.is_a?(Hash) && params["columns"].is_a?(Array) && params["columns"].empty?
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 untouched.
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
- return unless config_tables.is_a?(Hash)
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 for the table, columns are untouched.
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
- return unless list.is_a?(Array)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Json2sql
4
- VERSION = "1.0.14"
4
+ VERSION = "1.0.16"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json2sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago da Silva