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

Unscope select to avoid PG::UndefinedFunction #283

Merged
merged 2 commits into from Aug 30, 2018
Merged

Conversation

donv
Copy link
Contributor

@donv donv commented Jul 28, 2017

Having a default_scope with a select breaks since acts_as_list 0.9.5. The error type is discussed here:

rails/rails#19146

Unscoping the select scope fixes the problem.

@swanandp
Copy link
Collaborator

@donv Thanks for contributing. Can you please add a failing test case to demonstrate the problem?

@brendon
Copy link
Owner

brendon commented Jul 28, 2017

Hi @donv, should we be using count(:all) instead?

@donv
Copy link
Contributor Author

donv commented Jul 29, 2017

Yes, using count(:all) is probably a better solution, but it was a bigger change, so I tried for the smallest change I could see 😄 .

@brendon
Copy link
Owner

brendon commented Jul 29, 2017

Thanks @donv, I think count(:all) is probably the best way forward. What do you think @swanandp?

If you could switch to that method and provide a failing test that would be great :D

@brendon
Copy link
Owner

brendon commented Aug 10, 2017

Hi @donv, would you mind doing that fix with the test? :)

@donv
Copy link
Contributor Author

donv commented Aug 10, 2017

Hi @brendon !

No, I don't mind 😄 . Will put it on my plan for next week or the week after. Lots of things to do 😅 .

@brendon
Copy link
Owner

brendon commented Aug 10, 2017

Thanks @donv, we really appreciate it :)

@brendon
Copy link
Owner

brendon commented Oct 3, 2017

@donv: ping! :D

@donv
Copy link
Contributor Author

donv commented Oct 4, 2017

Thanks for the ping. My plan has slipped :) Will get to it.

@donv
Copy link
Contributor Author

donv commented Dec 5, 2017

Starting on this now.

@donv
Copy link
Contributor Author

donv commented Dec 5, 2017

I have added a failing test that becomes green with the current change.

@donv
Copy link
Contributor Author

donv commented Dec 5, 2017

I am trying to implement the count(:all) idea we had, but it proves complex since we expect to have the position_column available in many places. Having a default scope with a select results in the position column not being present in the resulting records.

I have tried a few ways to add the position_column to the query, but then we mess up the default select of all columns.

I now think my original idea is the best, to just unscope :select.

What do you think?

@brendon
Copy link
Owner

brendon commented Dec 5, 2017

Unscoping a default :select seems like an ok solution. As you say, it's unworkable not to have the position column selected. No damage can be done by unscoping the :select? There were side effects to unscoping a default :order which is why we now only unscope the :where.

@swanandp, did you have any feedback? :)

@brendon brendon mentioned this pull request Mar 8, 2018
@brendon
Copy link
Owner

brendon commented Mar 19, 2018

@donv, someone has proposed the unscope :select solution in a seperate pull request so I think we'll merge this one. Can you update from master just so we can get a green suite then we should be good to go :)

donv and others added 2 commits August 29, 2018 20:50
Having a `default_scope` with a `select` breaks since acts_as_list 0.9.5.  The error type is discussed here:

rails/rails#19146

Unscoping the `select` scope fixes the problem.
@donv
Copy link
Contributor Author

donv commented Aug 29, 2018

@brendon Rebased and green tests.

@brendon brendon merged commit fa83009 into brendon:master Aug 30, 2018
@brendon
Copy link
Owner

brendon commented Aug 30, 2018

Thanks @donv, I'm happy with this. I'll release a new gem for you.

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

Successfully merging this pull request may close these issues.

None yet

4 participants