Skip to content
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

Unreachable code in activerecord_extensions #6

Open
dave-gantenbein opened this issue Mar 15, 2011 · 1 comment
Open

Unreachable code in activerecord_extensions #6

dave-gantenbein opened this issue Mar 15, 2011 · 1 comment

Comments

@dave-gantenbein
Copy link

Hi-

If you call search_raw and it passes models as false to the indextank_search function, models gets set to a true value (empty array), and the raw never executes:

    models = []
    res = it.search("__any:(#{query.to_s}) __type:#{self.name}", options)
    if models # <---- I am always true!
        res['results'].each do |doc|
            type, docid = doc['docid'].split(" ", 2)
            models << self.find(id=docid)
        end
        return models
    else
        res['results'].each do |doc|
            type, docid = doc['docid'].split(" ", 2)
            doc['model'] = self.find(id=docid)
        end
        return res
    end

I've patched my local copy thusly, and now can access the raw results.

    res = it.search("__any:(#{query.to_s}) __type:#{self.name}", options)
    if models
        models = [] # <--- assign me after checking!
        res['results'].each do |doc|
            type, docid = doc['docid'].split(" ", 2)
            models << self.find(id=docid)
        end
        return models
    else
        res['results'].each do |doc|
            type, docid = doc['docid'].split(" ", 2)
            doc['model'] = self.find(id=docid)
        end
        return res
    end

With this change it seems to work both ways now.

@marcusg
Copy link

marcusg commented Oct 3, 2011

@rankindaveyg I've patched this error in my fork of thinkingtank and added a few minor fixes. You may want to get it: https://github.com/marcusg/thinkingtank
In addition I sent a pull request, but i'm not sure if the project is still maintained...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants