Skip to content

fix-finding-query-methods #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

fix-finding-query-methods #855

wants to merge 1 commit into from

Conversation

masarakki
Copy link

@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
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

cla-checker-service bot commented Apr 23, 2020

💚 CLA has been signed

@picandocodigo
Copy link
Member

jenkins test this please

@masarakki
Copy link
Author

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

@masarakki
Copy link
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
Author

please review it

@picandocodigo
Copy link
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
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