Skip to content

Commit 9203f2c

Browse files
jmksbrunoocasali
authored andcommitted
Apply attribute warning everywhere
1 parent 8db19a1 commit 9203f2c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/meilisearch/index.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ def delete_all_documents!
223223
def search(query, options = {})
224224
attributes = { q: query.to_s }.merge(options.compact)
225225

226-
Utils.warn_on_non_conforming_attribute_names(attributes)
227-
228226
parsed_options = Utils.transform_attributes(attributes)
229227
response = http_post "/indexes/#{@uid}/search", parsed_options
230228

lib/meilisearch/utils.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module Utils
55
SNAKE_CASE = /[^a-zA-Z0-9]+(.)/.freeze
66

77
def self.transform_attributes(body)
8+
warn_on_non_conforming_attribute_names(body)
9+
810
case body
911
when Array
1012
body.map { |item| transform_attributes(item) }
@@ -53,8 +55,9 @@ def self.version_error_handler(method_name)
5355
end
5456

5557
def self.warn_on_non_conforming_attribute_names(body)
56-
non_snake_case = body.keys.grep_v(/^[a-z0-9_]+$/)
58+
return if body.nil?
5759

60+
non_snake_case = body.keys.grep_v(/^[a-z0-9_]+$/)
5861
return if non_snake_case.empty?
5962

6063
message = <<~MSG

0 commit comments

Comments
 (0)