Thanks. I agree with you that things should be no surprise. Anyway, thank to datamapper team to give me an amazing library.
On Oct 2, 8:06 am, Jacques Crocker <[email protected]> wrote: > Hi sliu. This is the same issue that I had earlier with dm-timestamps. > In datamapper, save! will cause the before filters to NOT run, causing > these errors. Use A.new.save and you should be fine. > > Dan, sorry to say, but this is going to keep causing many problems for > people unless we really focus on educating people not to use save!, > create!, etc. I honestly think its easier to make it work like people > expect (have save! work like AR) :-) > > On Oct 1, 2009, at 5:02 PM, sliu wrote: > > > > > See the following code: > > > class A > > include DataMapper::Resource > > property :id, Serial > > > is :tree > > end > > > A.auto_migrate! > > > A.new.save! > > > The last line will raise exception: > > > /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm-core/ > > adapters/data_objects_adapter.rb:162:in `execute_non_query': Field > > 'parent_id' doesn't have a default value (DataObjects::SQLError) > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:162:in `execute' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:266:in `with_connection' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:160:in `execute' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:58:in `create' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:31:in `each' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/adapters/data_objects_adapter.rb:31:in `create' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/repository.rb:125:in `create' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/resource.rb:808:in `_create' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/resource.rb:556:in `save_self' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-validations-0.10.1/ > > lib/ > > dm-validations.rb:55:in `save_self' > > from /usr/local/ruby/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm- > > core/resource.rb:354:in `save!' > > > This is because auto_migration generate `parent_id` column with NOT > > NULL option, and when I add a root node(parent_id is null), database > > won't pass. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
