-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Table names don't always get properly quoted #1631
Comments
If your fix is applied to dashboard.rb, I would just add the missing spec file and test there. You can always update a pull request if a maintainer comments that they would like something changed ;) |
Looks like this issue still exists as I've got the same problem currently. Is there any update on this? |
I also just hit that issue. |
I found the root cause: If not quoted postgres will downcase everything, so if I have a column name "FOO_BAR" and try to query it like See https://stackoverflow.com/a/2878408/3497181
Rails / ActiveModel itself does the correct thing, so if I execute Edit: Actually ActiveModel does only the right thing when passing the column name as symbol. If I pass it as |
In lib/rails_admin/config/actions/dashboard.rb, on line 30, it produces an SQL query that doesn't quote the table name referenced (SELECT "user".* FROM "user" ORDER BY user.updated_at desc). This is a problem if you have a table name like "user", which is a reserved word in PostgreSQL.
Here's a gist with a stack trace: https://gist.github.com/jasonswett/1da12e239266f20b17c2
I wrote a fix for this, but this would be my first open source contribution ever, so I might need a little hand-holding to get it in. I understand I'm supposed to write a failing spec, but I don't see a spec for dashboard.rb in what I would assume to be the logical place, spec/rails_admin/config/actions. If someone could help me find that, that would be appreciated.
The text was updated successfully, but these errors were encountered: