[Nitro] [BUG] bryan's og_manager_fix

Bryan Soto bryan.a.soto at gmail.com
Mon Jan 30 19:44:25 EST 2006


On 1/30/06, Chris Farmiloe <chris at motionpath.com> wrote:
>
>
>
> Hiya Bryan:
>
> Sorry my quick example may have been a little slapdash.
>
> Here is a slightly neater version. the error is the postgres error:
>
> Og.setup had problems: RuntimeError => ERROR   C42P01  Mrelation
> "ogclasstwo" does not existFnamespace.c    L201    RRangeVarGetRelid
>
>
> ogclasstwo obveously shouldn't exist since it should be using table
> 'ogclassone'
>
> works without patch, not with.
>
> Thanx
>
>
Hi,

I get it know; sorry for being dense.

Problem is:

# og/lib/og/entity.rb

    #--
    # farms/rp: is there not another way to access the root class?
    #++

    def schema_inheritance_root_class
      klass = self
-      until !Og.manager.manageable?(klass) or
klass.schema_inheritance_root?
+     until klass.schema_inheritance_root?
        klass = klass.superclass
      end
      return klass
    end

#manageable? was being used to find classes to manage. To prevent Og from
managing already managed classes, I modified it to exclude classes already
managed. Hence the problem. I made this change to accomodate multiple
stores. The way Og worked, it tried to enchant everything it could, even if
it was already managed.

I'm thinking the above change should be fine. It passes your test anyway. ;)


Seriously though, it doesn't appear to change a whole lot:

$ grep -R schema_inheritance_root_class * | grep -v '~' | grep -v def
og/store/sql.rb:    klass = klass.schema_inheritance_root_class if
klass.schema_inheritance_child?
og/store/sql.rb:    owner_class = owner_class.schema_inheritance_root_class
if owner_class.schema_inheritance_child?
og/store/sql.rb:    target_class =
target_class.schema_inheritance_root_class if
target_class.schema_inheritance_child?
og/store/sql.rb:      klass.const_set 'OGTABLE', table(
klass.schema_inheritance_root_class)
og/store/psql.rb:      klass.const_set 'OGSEQ', "#{table(
klass.schema_inheritance_root_class)}_oid_seq"

$ grep -R manageable? * | grep -v '~' | grep -v def
og/manager.rb:    manage(klass.superclass) if manageable?(klass.superclass)
og/manager.rb:      if manageable?(c)
og/entity.rb:      until !Og.manager.manageable?(klass) or
klass.schema_inheritance_root?

I note you and Rob are listed in the above code, so what do you two think?
I'm new to STI and I've already broken it, so I'll humbly leave it to the
two of you.

Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20060130/af6b1548/attachment.html 


More information about the Nitro-general mailing list