[Nitro] [FIX] find_or_create_by with relations

Bryan Soto bryan.a.soto at gmail.com
Wed Apr 5 02:36:12 EDT 2006


I'm not sure if this is a bug or an enhancement. I don't think what
Stephan was trying to do was supported by Og. What do you think? Is
this a good enhancement? Any other opinions? See
http://devlab.oree.ch/trac/nitrohq/ticket/29

Thanks,

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




More information about the Nitro-general mailing list