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

George Moschovitis george.moschovitis at gmail.com
Thu Aug 30 04:05:16 EDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20070830/899e211d/attachment.html 


More information about the Nitro-general mailing list