Bug in Og 0.26.0

Og 0.26.0 has a bug whereby schema_inheritance doesn’t work if you have more than one class inherit from the base class, and you are using the :evolve_schema => true in your Og.setup. Here is a patch which fixes that. I’ve submitted the patch to the Nitro team, but it won’t get rolled in until it … Continue reading “Bug in Og 0.26.0”

Og 0.26.0 has a bug whereby schema_inheritance doesn’t work if you have more than one class inherit from the base class, and you are using the :evolve_schema => true in your Og.setup.

Here is a patch which fixes that. I’ve submitted the patch to the Nitro team, but it won’t get rolled in until it has been thoroughly tested. Meanwhile, here it is in case you need it, in patch format.

diff -rN -u sql.rb /tmp/sql.rb 
--- sql.rb      2006-01-09 14:58:34.000000000 +1100
+++ /tmp/sql.rb 2006-01-09 14:57:35.000000000 +1100
@@ -595,8 +595,13 @@
       # holds the class name.
       fields << "ogtype VARCHAR(30)"
   
-      for desc in klass.descendents
-        properties.update(desc.properties)
+      # loop through superclasses up the inheritance chain, to ensure we don't miss any properties
+      superklass = klass.superclass
+      while (superklass.ancestors.include? SchemaInheritanceBase) do
+            for desc in superklass.descendents
+              properties.update(desc.properties)
+            end
+            superklass = superklass.superclass
       end
     end

Leave a Reply