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

Problems with pagination on Rails 4.1 #167

Closed
stefanocdn opened this issue Apr 28, 2014 · 25 comments
Closed

Problems with pagination on Rails 4.1 #167

stefanocdn opened this issue Apr 28, 2014 · 25 comments

Comments

@stefanocdn
Copy link

When adding pagination with either will_paginate or kaminari on Rails 41. I get these errors

In production

PG::Error: ERROR:  syntax error at or near "AS"
LINE 1: ...ish', ''' ' || '"Hello"' || ' ''' || ':*')), 0))) AS pg_sear...
SELECT COUNT("courses".*, ((ts_rank((to_tsvector('english', coalesce("courses"."title"::text, '')) || to_tsvector('english', coalesce("courses"."description"::text, '')) || to_tsvector('english', coalesce(pg_search_af6eda8ef968c5c8985fe1.pg_search_e990baea28e0dd3a28b167::text, ''))), (to_tsquery('english', ''' ' || '"Hello"' || ' ''' || ':*')), 0))) AS pg_search_rank) FROM "courses" LEFT OUTER JOIN (SELECT "courses"."id" AS id, string_agg("categories"."name"::text, ' ') AS pg_search_e990baea28e0dd3a28b167 FROM "courses" INNER JOIN "categories" ON "categories"."id" = "courses"."category_id" GROUP BY "courses"."id") pg_search_af6eda8ef968c5c8985fe1 ON pg_search_af6eda8ef968c5c8985fe1.id = "courses"."id" WHERE "courses"."active" = 't' AND (((to_tsvector('english', coalesce("courses"."title"::text, '')) || to_tsvector('english', coalesce("courses"."description"::text, '')) || to_tsvector('english', coalesce(pg_search_af6eda8ef968c5c8985fe1.pg_search_e990baea28e0dd3a28b167::text, ''))) @@ (to_tsquery('english', ''' ' || '"Hello"' || ' ''' || ':*'))))

And Development

ActiveRecord::StatementInvalid: PG::Error: ERROR:  syntax error at or near "AS"
LINE 1: ...ish', ''' ' || 'query' || ' ''' || ':*')), 0))) AS pg_sear...
                                                             ^
: SELECT COUNT("courses".*, ((ts_rank((to_tsvector('english', coalesce("courses"."title"::text, '')) || to_tsvector('english', coalesce("courses"."description"::text, '')) || to_tsvector('english', coalesce(pg_search_af6eda8ef968c5c8985fe1.pg_search_e990baea28e0dd3a28b167::text, ''))), (to_tsquery('english', ''' ' || 'query' || ' ''' || ':*')), 0))) AS pg_search_rank) FROM "courses" LEFT OUTER JOIN (SELECT "courses"."id" AS id, string_agg("categories"."name"::text, ' ') AS pg_search_e990baea28e0dd3a28b167 FROM "courses" INNER JOIN "categories" ON "categories"."id" = "courses"."category_id" GROUP BY "courses"."id") pg_search_af6eda8ef968c5c8985fe1 ON pg_search_af6eda8ef968c5c8985fe1.id = "courses"."id" WHERE "courses"."active" = 't' AND (((to_tsvector('english', coalesce("courses"."title"::text, '')) || to_tsvector('english', coalesce("courses"."description"::text, '')) || to_tsvector('english', coalesce(pg_search_af6eda8ef968c5c8985fe1.pg_search_e990baea28e0dd3a28b167::text, ''))) @@ (to_tsquery('english', ''' ' || 'query' || ' ''' || ':*'))))
from /Users/stephanecedroni/.gem/ruby/2.1.0/gems/rack-mini-profiler-0.1.31/Ruby/lib/patches/sql_patches.rb:155:in `exec'

Any idea what's wrong with pagination and Rails 4.1 ? It was working on Rails 3.2

@O-I
Copy link

O-I commented Apr 29, 2014

I've had this issue, too, using will_paginate, pg_search, and Rails 4.1. Works if I roll back to Rails 4.0.4. I'll see if I can play around with it to get some more specifics.

This might be a duplicate of some recently closed issues: See 158 and 153

@stefanocdn
Copy link
Author

ok, let me know if you can make it work with rails 4.1.

For now I had to convert some objects to array instead of activerecord relation. It is in particular the per_page method that create problems.

On 29 avr. 2014, at 14:01, O-I notifications@github.com wrote:

I've had this issue, too, using will_paginate, pg_search, and Rails 4.1. Works if I roll back to Rails 4.0.4. I'll see if I can play around with it to get some more specifics.


Reply to this email directly or view it on GitHub.

@O-I
Copy link

O-I commented Apr 29, 2014

This seems to have been fixed with this pull request to will_paginate. It hasn't been merged yet, but you can test it out yourself using this fork. It's working for me. Hopefully it doesn't introduce any new problems and will get merged in soon.

@stefanocdn
Copy link
Author

great, will try it out
thx

On 29 avr. 2014, at 17:50, O-I notifications@github.com wrote:

This seems to have been fixed with this pull request to will_paginate. It hasn't been merged yet, but you can test it out yourself using this fork. It's working for me. Hopefully it doesn't introduce any new problems and will get merged in soon.


Reply to this email directly or view it on GitHub.

@natebird
Copy link

natebird commented May 6, 2014

This is actually a Rails issue that will be included in 4.1.1.

mislav/will_paginate#372 (comment)

Although it isn't a pg_search or will_paginate issue, it may be worth keeping this issue open until it is resolved in Rails because this was the first place I looked. Thanks!

@O-I
Copy link

O-I commented May 6, 2014

OK, good to know. Only updating to Rails 4.1.1 still throws the ActiveRecord::StatementInvalid error for me, though. Anyone else still have this issue?

@natebird
Copy link

natebird commented May 6, 2014

@O-I really? I haven't tried it yet. I'll try later and report back with my findings. sigh

@natebird
Copy link

natebird commented May 6, 2014

It looks like this release is just the security commits.

http://weblog.rubyonrails.org/2014/5/6/Rails_3_2_18_4_0_5_and_4_1_1_have_been_released/

In order to make upgrading as smooth as possible, we've only included commits directly related to each security issue.

So 4.1.2?

@O-I
Copy link

O-I commented May 6, 2014

Yes, indeed. Rails 4.1.1 is just security commits. Thanks for the clarification.

@jakepetroules
Copy link

I can confirm the 4-1-stable branch of Rails fixes this issue. Eagerly awaiting 4.1.2!

@nertzy
Copy link
Collaborator

nertzy commented May 16, 2014

Closing as this is a Rails issue, not a pg_search issue. Thanks to everyone who jumped in and figured it out!

@nertzy nertzy closed this as completed May 16, 2014
@maxwell
Copy link

maxwell commented May 20, 2014

FWIW, I am still seeing this even with trying the latest master from rails/4-1-stable

@skatkov
Copy link

skatkov commented May 24, 2014

I'm still facing this problem with rails 4.1.1

@AndreaBarbon
Copy link

Me too...

@jakepetroules
Copy link

Guys, try 4.1.2.rc1 - I've been using that without any issues. 4.1.1 was security updates only.

@AndreaBarbon
Copy link

By the way, the error was generated by this line in the view:
<% if @jokes.empty? %>
and it can be fixed by changing it into
<% if @jokes.count(:all) == 0 %>
while the classic
<% if @jokes.count == 0 %>
still throws the error

@jakepetroules
Copy link

Hm, I remember seeing that same issue you mentioned with count but I'm pretty sure empty? still worked.

@AndreaBarbon
Copy link

I can confirm that empty? does not work. Using Rails 4.1.1 and the latest versions of pg_search and will_paginate

@jakepetroules
Copy link

Like I said, 4.1.2.rc1 is the first version to include the fix, not 4.1.1.

@skatkov
Copy link

skatkov commented Jun 14, 2014

Release Candidate is a little bit risky for production environment?

@AndreaBarbon
Copy link

Looks like stable releases are not that safe, too ;-)

@maxwell
Copy link

maxwell commented Jun 16, 2014

We have been using the RC to fix this problems and have not run into any
more issues.

On Sat, Jun 14, 2014 at 9:13 AM, AndreaBarbon notifications@github.com
wrote:

Looks like stable releases are not that safe, too ;-)


Reply to this email directly or view it on GitHub
#167 (comment)
.

maxwell salzberg - BackerKit, founder
skype: max.salzberg
p: (203) 451-3600
email: maxwell@backerkit.com
twitter: @maxwellsalz

@alexbel
Copy link

alexbel commented Jun 18, 2014

4.1.2.rc1 and rc2 don't work for me.
pg 0.17.1
pg_search 0.7.4
will_paginate 3.0.5

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near "AS"
LINE 1: ...query('simple', ''' ' || 'my query' || ' ''')), 0))) AS pg_sear...

Am I doing something wrong?

@DazDotOne
Copy link

Just updated rails to 4.1.2 and still have the same issue:

ActionView::Template::Error:
PG::SyntaxError: ERROR: syntax error at or near "as"
LINE 2: ... users.first_name, users.first_name as f_name,...
^
: SELECT COUNT(feedback_records.*,

@alexbel
Copy link

alexbel commented Jul 2, 2014

It's not pg_search.
I use will_paginate from master branch, rails 4.1.2. and pg_search 0.7.4. It works well.

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

10 participants