[Nitro] many_to_many delete bug
Robert Mela
rob at robmela.com
Wed Nov 14 08:59:31 EST 2007
Just for reference -- the other showstopper is in
http://rubyforge.org/pipermail/nitro-general/2007-November/008957.html
The new issue is delete in a many_to_many relation:
robert-melas-computer:~/projects/og rmela$ ruby tagtest.rb INFO: Og
uses the Sqlite store.
Program inserting tag1
Collection#initialize: Collection initialized with remove_proc = remove_tag
Created tags collection with remove proc=remove_tags
Collection#push Entered Collection.push(tag1) with tag=tag1. Owner is
#<Post:0x15911e4>
Program calling save
Deleting tag
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store/sql.rb:144:in
`og_delete': uninitialized constant Og::SqlEnchantmentMixin::BelongsTo
(NameError)
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store/sql.rb:139:in
`each'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store/sql.rb:139:in
`og_delete'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store.rb:216:in
`transaction_raise'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/model.rb:196:in
`transaction_raise'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/manager.rb:118:in
`with_store'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/model.rb:195:in
`transaction_raise'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store/sql.rb:137:in
`og_delete'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/store.rb:153:in
`delete'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/model.rb:181:in
`delete'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/manager.rb:118:in
`with_store'
from
/Users/rmela/nitro/branch/script/lib/../../og/lib/og/model.rb:180:in
`delete'
from tagtest.rb:31
Here's code that triggers it. I tried p.remove_tag(t1) and p.save!
before the delete -- still no dice. Even if that did work it'd be a
workaround, and unintuitive.
#!/opt/local/bin/ruby
require 'og'
require 'sqlite3'
class Post
attr_accessor :name, String
is Taggable
end
Og.start(
:adapter => 'sqlite',
:name => 'tagtest',
:destroy_schema => true,
:create_schema => true
)
p=Post.new
p.name = 'post1'
t1 = Tag.new
t1.name = 'tag1'
puts "Program inserting tag1"
p.tags << t1
puts "Program calling save"
p.save!
puts "Deleting tag"
t1.delete
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20071114/bbd7263a/attachment.vcf
More information about the Nitro-general
mailing list