On Monday, October 22, 2012 5:30:59 PM UTC-7, GregD wrote: > > All, > > Something possible broken with one_to_one. I have an older rails project > that I just updated using bundle and I'm getting this: > In the future, please include an SQL log along with the backtrace, as it makes it easier to diagnose the cause of the issue.
Sequel::Error: Record not found > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1534:in > > `_refresh' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/associations.rb:1509:in > > `_refresh' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1609:in > > `_save_refresh' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1596:in > > `_save' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1233:in > > `block (2 levels) in save' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1701:in > > `block in checked_transaction' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/database/query.rb:323:in > > `_transaction' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/database/query.rb:285:in > > `block in transaction' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:229:in > > `block in synchronize' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/connection_pool/threaded.rb:105:in > > `hold' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:229:in > > `synchronize' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/database/query.rb:278:in > > `transaction' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1701:in > > `checked_transaction' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1233:in > > `block in save' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1692:in > > `checked_save_failure' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:1233:in > > `save' > from > /Users/gregd/.rvm/gems/ruby-1.9.3-p286@euchre/gems/sequel-3.40.0/lib/sequel/model/base.rb:163:in > > `create' > from (irb):4 > This backtrace indicates that after inserting the record, Sequel cannot select the row to get the current values of the fields. That can be caused by insert not returning the correct primary key, and possibly other things. I'm not sure which line in the code posted below caused this backtrace, and without an SQL log, it's pretty hard to diagnose what the underlying cause is. > This occurs when I the code is trying to assign a configuration to a > tournament. > > class Tournament < Sequel::Model > one_to_one :configuration, :class => TournamentConfiguration > end > > class TournamentConfiguration < Sequel::Model > many_to_one :tournament > end > > Tournament.first.configuration = TournamentConfiguration.create > > It seems I can not create a TournamentConfiguration. I even tried: > > TournamentConfiguration.create(:tournament => Tournament.first) > It's better to use many_to_one setters instead of one_to_one setters, especially for new records (since one_to_one setters cause saves), but both of the code lines you posted appear to be valid. Any help? Am I doing something wrong? Is one_to_one not supported anymore > and should I just use one_to_many for this? > one_to_one is supported and works fine, there is probably something special about your environment that is causing it to fail. If you could produce a self-contained example displaying the error, that would be best, but even just an SQL log should make it easier to diagnose the cause. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/K1FqlHXxVZsJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
