[Nitro] OG: Model#instance_attribute_set silently updates Model#new instances using WHERE oid=NULL

Mark Van De Vyver mvyver at gmail.com
Thu Aug 30 04:10:55 EDT 2007


Hi George,
Thank you and the other developers! - the more I see of Og the more
I'm impressed by it.
Related to that example:

Using irb:

## Works
mysql.store.save( Member.new(FIXTURE) )

## Fails
# mysql.store.insert( Member.new(FIXTURE) )
ArgumentError: wrong number of arguments (1 for 2)
        from (irb):113:in `insert'
        from (irb):113
        from :0

In the ri documents it seems just one argument is required:
Og::Store#insert insert(obj)
Insert an object in the store.

HTH
Mark

On 8/30/07, George Moschovitis <george.moschovitis at gmail.com> wrote:
> thansk for the report, I will investigate this issue later today.
>
> -g.
>
>
> On 8/30/07, Mark Van De Vyver <mvyver at gmail.com > wrote:
> >
> > Hi,
> > I've been working through some examples and came across the following
> behavior.
> > I'm posting this here since there is an error page instead of the
> > ticket system at:
> > http://www.nitroproject.org/tickets
> >
> > Without the '$DBG = true' setting there would be no hint that the last
> > statement was unsuccessful.
> > I'm not sure if an exception should be thrown, or the record should
> > just be saved (when saved? -> nil) before updating.
> >
> > HTH
> > Mark
> >
> > #-----------------------------
> > require 'rubygems'
> > require 'og'
> >
> > # Full debug information.
> > $DBG = true
> >
> > mysql_config = {
> >   :name => 'test',
> >   :store => 'mysql',
> >   :user => 'root',
> >   :password => '',
> >   :destroy=>false
> > }
> >
> > # keeping it simple
> > class SimplerMember
> >   attr_accessor :first_name, :last_name, :address1, :city, :state,
> > :email, String
> > end
> >
> >   # define some data.
> >   FIXTURE = { :first_name => 'Fred', :last_name => 'Flintstone',
> >               :address1 => '123 High St.', :city => 'Reykjavik',
> >               :state => 'Michigan', :email => ' fred at flintstone.com' }
> >
> >   # Initialize Og.
> >   mysql = Og.connect(mysql_config)
> >
> >   # This will INSERT an empty row, then make an UPDATE for each
> >   # attribute/field using WHERE oid=<some_number>
> >   simmem_rec = SimplerMember.create
> >   FIXTURE.each { |key, value|
> > simmem_rec.instance_attribute_set("#{key}", value) }
> >
> >   #This does an UPDATE for each field using WHERE oid=NULL
> >   simmem_rec = SimplerMember.new
> >   FIXTURE.each { |key, value|
> > simmem_rec.instance_attribute_set("#{key}", value) }
> >
> > #-----------------------------
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general
> >
>
>
>
> --
> http://www.me.gr
> http://phidz.com
> http://blog.gmosx.com
> http://cull.gr
> http://www.joy.gr
> http://nitroproject.org


More information about the Nitro-general mailing list