-
Notifications
You must be signed in to change notification settings - Fork 39
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
Problem with custom select / PG function #7
Comments
Product.select("products.id as xyz").last.xyz
=> 1
Product.eager_load(:comments).select("products.id as xyz").last.xyz
=> NoMethodError: undefined method `xyz' for ... I don't consider this to be a bug in SearchCop as the use of eager_load is clearly stated. However, to fix it you currently have to do the join-logic yourself via a In case you need help with the join logic, just call. |
Thank you for reply, mrkamel! |
Ok, please post your current BTW, there already are examples regarding custom |
Yes, that's exactly what i have mentioned in #5 :) Yes, i'm definatelly not denying that it's AR issue rather than SearchCop, i'm just using SearchCop in my production commercial app and this one thing stops me from making a final deploy before a deadline which has passed on friday. That's why i'm kind of desperate and not able to deal with that on my own. Therefore, i'm 100 times more thankfull for your will to help me with that thing :) |
So, is #5 sufficient to get the thing done? If not, please post your current |
Oh, sorry, i've made a horrible mistake. I meaned completely different model and the #5 task is completely not relevant. Here is my code:
Thanks! |
Hm, your search_scope doesn't search within attributes of an associated model at all. Thus, SearchCop won't |
Sure, here it is: Without
|
I don't fully understand. You're using Otherwise, please tell me what the rails console tells you about |
Oh crap, sorry, you're right, there was a typo in the first lines of provided code samples, they should be |
What happens when you run the sql generated for |
Yes, running generated query in pgadmin returns desired columns. i'm not |
Ok, the problem is SearchCop calls |
Great to hear it's tracked down. Thank you for your help and time mrkamel! I'm looking forward to the patch. |
Could you confirm, that this fixes your issue, before i bump a new gem version? gem "search_cop", :git => "https://github.com/mrkamel/search_cop.git"
|
Yes, now it works. Thank you so much! |
Hello!
i'm trying to use search_cop with my quite complex model code. Basically, i have a custom postgres function and i'm using it like that:
However, when i apply a search_cop method
search()
to the code above, i'm not able to access mycustom_function
result row:What's more interesting - i can see that db query produced by the chain above looks quite proper and i'm able to use it in pgAdminII which gives me a
custom_function
column with the proper value.Have you any idea what can be wrong in here or what can i do about it?
Thanks in advance.
The text was updated successfully, but these errors were encountered: