parseresource sorting by order not supported #3

Closed
akashb opened this Issue Jan 5, 2012 · 17 comments

Comments

Projects
None yet
4 participants

akashb commented Jan 5, 2012

When I call order for sorting, the query is not lazy loaded and comes out with an Exception saying --- undefined method 'order'

Owner

adelevie commented Jan 5, 2012

@akashb can you give me instructions to reproduce the error, as well as the stack trace from your error and the version of parse_resource you are using?

akashb commented Jan 6, 2012

If you query sort using order on any ParseResource class it gives that error.
I am using parse_resource 1.7.1

Stack trace:
(rdb:14) pp @zip = Post.order("zip")
NoMethodError Exception: undefined method `order' for Post:Class
(rdb:14) pp Post.first
#<Post:0x4c87aa0
@attributes=
{"city"=>"Palo Alto",
"zip"=>"94022",
"createdAt"=>"2011-11-15T06:12:05.379Z",
"updatedAt"=>"2011-11-15T06:12:05.379Z",
"objectId"=>"0pPGuolAT5"},
@unsaved_attributes={}>

Owner

adelevie commented Jan 6, 2012

Thanks, @akashb. I'll investigate. Keep in mind, #order was never fully working in the first place. It's still in progress--that's why I didn't include any examples in the README.

akashb commented Jan 6, 2012

Thanks @adelevie for maintaining parse_resource. Parse query REST interface supports database queries with #order sorting. I am curious, as to what the issue is in implementing #order in parse_resource?

Hi, I think the problem is that version tagged ~1.7.1 doesn't include the '''order''' method. This method is properly working as defined in the master branch:

def order(attribute)
    attribute = attribute.to_sym if attribute.is_a?(String)
    criteria[:order] = attribute
    self
end
Owner

adelevie commented Jan 19, 2012

@albertovilla, thanks. Unfortunately that's not the root of the problem. Try running the order test a few times and you'll get inconsistent results. It's implemented in master, but still doesn't work.

@adelevie I will take a look at it; my initial tests were running ok, I will implement some others to execute the order function several times.

Owner

adelevie commented Jan 19, 2012

Thanks a lot, @albertovilla. Are you planning on sending a pull request/contribution at some point?

Yes, in fact, I'm thinking on the possibility of contributing with this error bug (if I'm able to solve it) and the GeoPoint part of the API (I don't know if you have started with that already)

Owner

adelevie commented Jan 19, 2012

@albertovilla, that would be great, thanks!

For GeoPoints, open an issue, and we can discuss different API designs in that thread.

@adelevie I've implemented some additional tests but I've not been able to reproduce the error.

I've created a list of posts with titles a..z and I've checked the order of those (which is correct). Then I've called order method three times (three is just an example I could make the call more times but it takes long to execute) and I've compared each of the titles of the posts with the original ordered posts and the results are coincident (i.e. the order is fine).

Could you provide me an example of the "inconsistent results" you've discovered?

Owner

adelevie commented Jan 20, 2012

Can you push those changes as a pull request? If they run properly on my end, I'll just merge it into master.

No problem, I've just made the pull request; you can run the test by executing bundle exec rspec spec/ (inside the test/ordertest directory)

Owner

adelevie commented Jan 21, 2012

Thanks a lot. I'll review and hopefully merge tomorrow. You will be the first contributor :)

Contributor

mattvv commented Mar 23, 2012

I'm trying this using the master branch - method chaining the .order command doesn't work. Here's an example:

@scripts = Script.where(:username => @current_user.username).order(:createdAt).all

undefined methodorder' for #Query:0x00000100a2cd98`

Contributor

mattvv commented Mar 23, 2012

Nevermind it looks like this was to do with RubyGems, I used master branch and this now works! Yay!

Owner

adelevie commented Mar 23, 2012

Thanks for figuring this out. There's a good amount of technical debt in the codebase, and I need all the help I can get to remove it. If you're interested, email me.

@adelevie adelevie closed this Mar 23, 2012

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