[Nitro] [FIX] find_or_create_by with relations

Bryan Soto bryan.a.soto at gmail.com
Sun Apr 2 12:54:33 EDT 2006


I'm sorry. Thanks for the patch Stephan. :)

On 4/2/06, Bryan Soto <bryan.a.soto at gmail.com> wrote:
> Thanks for the patch Walter. I've created a ticket on devlab so we
> wouldn't lose track of this.
>
> http://devlab.oree.ch/trac/nitrohq/ticket/29
>
> Bryan
>
> On 4/2/06, George Moschovitis <george.moschovitis at gmail.com> wrote:
> > Thanks, i will review this shortly.
> >
> > -g.
> >
> > On 4/2/06, Stephan Walter <news at stephan.walter.name> wrote:
> > > Hi,
> > >
> > > Og currently has a problem with find_or_create_by_* if the object has
> > > relations. The find will execute correctly, but when no object is found,
> > > the creation of the new object will not include the relations.
> > >
> > > Made-up example:
> > >
> > >   class A
> > >     property :name
> > >     belongs_to :b, B
> > >   end
> > >
> > >   class B
> > >   end
> > >
> > >   A.find_or_create_by_name_and_b("foo", @b)
> > >
> > > This will result in the correct SELECT statement:
> > >
> > >   SELECT * FROM a WHERE name = 'foo' AND b_oid = 1
> > >
> > > If no object is found, the following INSERT statement will be wrong, the
> > > b_oid should not be NULL:
> > >
> > >   INSERT INTO a (name,b_oid,oid) VALUES ('foo',NULL,NULL)
> > >
> > > The patch at http://84.16.238.99/files/entity.rb.patch fixes this. However
> > > I am not sure if the patch does the right thing, and I have not tested it
> > > a lot. It'd be great if someone could look into this.
> > >
> > > -Stephan
> > >
> > >
> > > _______________________________________________
> > > Nitro-general mailing list
> > > Nitro-general at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/nitro-general
> > >
> >
> >
> > --
> > http://www.gmosx.com
> > http://www.navel.gr
> > http://www.nitrohq.com
> >
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general
> >
>
>
> --
> "Never tell people how to do things. Tell them what to do and they
> will surprise you with their ingenuity." —General George S. Patton
>


--
"Never tell people how to do things. Tell them what to do and they
will surprise you with their ingenuity." —General George S. Patton




More information about the Nitro-general mailing list