Skip to content

fix-finding-query-methods#855

Closed
masarakki wants to merge 1 commit intoelastic:mainfrom
masarakki:fix-finding-query-methods
Closed

fix-finding-query-methods#855
masarakki wants to merge 1 commit intoelastic:mainfrom
masarakki:fix-finding-query-methods

Conversation

@masarakki
Copy link
Copy Markdown

@masarakki masarakki commented Apr 23, 2020

Queirs.const_defined? 'Foo' find not only Queries::Foo but also ::Foo,
so if program has Foo class, this method_missing call Foo.new instead of call foo method.

class Foo
   include ActiveModel::Model
   include ActiveModel::Attributes

   attribute :name, :string
end

class SearchForm
  include ActiveModel::Model
  include ActiveModel::Attributes
  include Elasticsearch::DSL

  attribute :foo

  def condition
    search do
      query do
        bool { must { term name: foo.name } }
      end
    end
  end
end

p SearchForm.new(foo: Foo.new(name: 'hello')).condition.to_hash
  • expect: {:query=>{:bool=>{:must=>[{:term=>{:name=>"name"}}]}}}
  • actual: {:query=>{:bool=>{:must=>[{:term=>{:name=>nil}}]}}}

@elasticmachine
Copy link
Copy Markdown
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link
Copy Markdown

cla-checker-service bot commented Apr 23, 2020

💚 CLA has been signed

@picandocodigo
Copy link
Copy Markdown
Member

jenkins test this please

@masarakki
Copy link
Copy Markdown
Author

I agreed CLA, but status not changed. Is there anything I must do?

@masarakki
Copy link
Copy Markdown
Author

Hmm? after comment, status changed immediately.

`Queirs.const_defined? 'Foo'` find not only `Queries::Foo` but also `::Foo`,
so if program has `Foo` class, this `method_missing` call `Foo.new` instead of call `foo` method.
@masarakki
Copy link
Copy Markdown
Author

please review it

@picandocodigo
Copy link
Copy Markdown
Member

Hi @masarakki,
Thank you for your contribution! I am currently working on other priorities, but I will soon review the Pull Requests for the DSL library and hopefully release a new version with new fixes and updates 👍

@picandocodigo
Copy link
Copy Markdown
Member

Moved to the new repository. Thanks @masarakki!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants