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

bug results in error: ActiveRecord::StatementInvalid in RailsAdmin::MainController#dashboard #2210

Closed
carlcotner opened this issue Mar 9, 2015 · 4 comments

Comments

@carlcotner
Copy link

My Rails/Devise User table is "user", which seems to be a reserved word for Postgres, and rails_admin generates the following SQL

SELECT "user".* FROM "user" ORDER BY user.updated_at desc LIMIT 1

without quoting the ORDER BY "user", which results in the error given in the subject line. The rest of the error message is

PG::SyntaxError: ERROR: syntax error at or near "." LINE 1: SELECT "user".* FROM "user" ORDER BY user.updated_at desc ... ^ : SELECT "user".* FROM "user" ORDER BY user.updated_at desc LIMIT 1

and the error happens here:

Extracted source (around line #592):

590
591 def exec_no_cache(sql, name, binds)
592 log(sql, name, binds) { @connection.async_exec(sql, []) }
593 end
594
595 def exec_cache(sql, name, binds)

@carlcotner
Copy link
Author

(Or maybe this is actually a problem with ActiveRecord?)

@fmh
Copy link
Contributor

fmh commented Mar 9, 2015

maybe try create table "users"

@carlcotner
Copy link
Author

Yeah, thanks, I thought of that, but I'd have to change my whole application, so it is not my first choice. Do you happen to know whether the lack of table name quoting in the ORDER BY clause is a rails_admin problem or an ActiveRecord problem?

@mshibuya
Copy link
Member

Dup of #1631.

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

3 participants