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

Using postgres, .last? returns false when there is a null in the positioning after the real last record #1

Open
ghost opened this issue Aug 16, 2011 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 16, 2011

This looks like a bug in the acts_as_list plugin when detecting whether its the last record in a set.

Requirement.find(83077).requirement_category.requirements.map(&:position)
=> [1, 2, 3, nil]
Requirement.find(83080).last?
=> false

Last? should return true!
Daniel Rice16 Aug 2011, 4:13pm
ActiveRecord::Relation can find the maximum and minimum values using database functions to find it.

Requirement.find(83077).requirement_category.requirements.maximum(:position)
=> 3

Requirement.find(83077).requirement_category.requirements.minimum(:position)
=> 1

So the first? and last? equality checks check the position column against acts_as_list_class.scope_conditions.maximum(

Looks like the first? method will work just fine. Its the last? method that needs to get updated. I will fork the acts_as_list plugin and bring it under highgroove's wing, fix it, and update Star's dependencies accordingly.

https://www.pivotaltracker.com/story/show/17086285

ghost pushed a commit that referenced this issue Aug 16, 2011
…t any null records. Postgres will order any items removed from the list at the top, which breaks this method when using acts_as_list with postgres.
@ghost
Copy link
Author

ghost commented Aug 16, 2011

@ghost
Copy link
Author

ghost commented Aug 16, 2011

Need to test this using postgres adapter. The documentation for Active Record helps detail a way to do this.

https://github.com/rails/rails/blob/master/activerecord/RUNNING_UNIT_TESTS#L21

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

0 participants