[Nitro] [FIX] find_or_create_by with relations

Stephan Walter news at stephan.walter.name
Sun Apr 2 08:39:21 EDT 2006


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

  class B

  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 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.


More information about the Nitro-general mailing list