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

quoted_table_name with abstract models #217

Closed
matiasleidemer opened this issue Oct 31, 2013 · 3 comments
Closed

quoted_table_name with abstract models #217

matiasleidemer opened this issue Oct 31, 2013 · 3 comments
Labels

Comments

@matiasleidemer
Copy link

When updating to Rails 4, I've encountered a nasty error message:

ActiveRecord::StatementInvalid:
PG::SyntaxError: ERROR:  zero-length delimited identifier at or near """"
LINE 1: ..._table".* FROM "my_table"   ORDER BY ""."rgt" d...
                                                                    ^
: SELECT  "my_table".* FROM "my_table" ORDER BY ""."rgt" desc LIMIT 1

The model implementing nested_set is quite simple:

class MyModel < ActiveRecor::Base
  self.abstract_class = true

  acts_as_nested_set
end

Everything was fine with Rails 3.2, but when updating to Rails 4, it started to break. After some source digging I've seen this: https://github.com/collectiveidea/awesome_nested_set/blob/master/lib/awesome_nested_set/model.rb#L17

The delegation of quoted_table_name to self isn't working anymore (at least with abstract models) and I guess it may be related with this issue rails/rails#10658.

Defining self.quoted_table_named in my abstract model seems to solve the problem, though it feels a little hacky, and may not be the perfect solution for everybody facing this problem.

Not sure if this is an awesome_nested_set issue (I really don't think so) but I think it's important to point that out.

@matiasleidemer
Copy link
Author

Actually this is happening with Rails 3.2 too, not only Rails 4, my mistake...

@petergoldstein
Copy link
Contributor

@matiasleidemer Do you have a spec drawn up that can demonstrate this issue? I think I have a fix, but I want to make sure I'm fixing the right thing.

@stale
Copy link

stale bot commented Jan 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 11, 2021
@stale stale bot closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants