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

destroy_all throws an error if there is an nil position in the list. #1

Open
treybean opened this issue Feb 19, 2010 · 1 comment
Open
Labels

Comments

@treybean
Copy link
Member

class Recommendation < ActiveRecord::Base
acts_as_restful_list :scope => :list
end

on postgres:

Recommendation.destroy_all returns

ActiveRecord::StatementInvalid: PGError: ERROR: syntax error at or near ")"
LINE 1: ...sition = (position - 1) WHERE (list_id = 1 AND position > )
^
: UPDATE "recommendations" SET position = (position - 1) WHERE (list_id = 1 AND position > )
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in log' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:550:inexecute'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in update_sql' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:561:inupdate_sql'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:49:in update_without_query_dirty' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:18:inupdate'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:847:in update_all' from /Library/Ruby/Gems/1.8/gems/acts_as_restful_list-0.1.0/lib/acts_as_restful_list.rb:55:inreset_order_after_destroy'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in send' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:inevaluate_method'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in call' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:inrun'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in each' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:insend'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in run' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:inrun_callbacks'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in callback' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:338:indestroy_without_transactions'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in send' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:inwith_transaction_returning_status'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:intransaction'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:228:in with_transaction_returning_status' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:192:indestroy'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:877:in destroy_all' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:877:ineach'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:877:in `destroy_all'

@treybean
Copy link
Member Author

Discovered this is only if one of the item's position is nil

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

1 participant