[Nitro] [FIX] find_or_create_by with relations

George Moschovitis george.moschovitis at gmail.com
Sun Apr 2 11:53:40 EDT 2006


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




More information about the Nitro-general mailing list