[Nitro] SchemaInheritance and Foreign Keys

Kashia Buch kashia at vfemail.net
Wed Dec 28 18:31:24 EST 2005


Hi,

I think I found a bug with schema inheritance and foreign key handling.

A small example: (hope it doesn't get mangled up too much by my email  
client)

# Class File
class File
   is Og::SchemaInheritanceBase

   property :title, String
   belongs_to Container
   belongs_to CD
end # end class File

# Class VideoFile
class VideoFile < File
   has_one :videofiletype, FileType
   has_one :quality, FileQuality
end # end class VideoFile

produces:

DEBUG -- : PostgreSQL processing foreign key constraints
ERROR -- : PostgreSQL connection returned an error for query ALTER TABLE  
ogfile ADD CONSTRAINT
ogc_ogfile_quality_oid FOREIGN KEY (quality_oid) REFERENCES ogquality(oid)  
ON UPDATE SET NULL ON DELETE SET
NULL
ERROR -- : Og.setup had problems: PGError => ERROR:  column "quality_oid"  
referenced in foreign key constraint
does not exist

after this the psql table looks like:
videolist=# \d ogfile
     Column     |         Type          | Modifiers
---------------+-----------------------+----------
  ogtype        | character varying(30) |
  title         | text                  |
  container_oid | integer               |
  c_d_oid       | integer               |
  oid           | integer               | not null..


so what I'm guessing is, that the "foreign key construction" comes too  
early. Should be some "if
klass.ancestors.include?(SchemaInheritanceBase) then delay foreign key  
construction". I hope George or someone
else can make sense of that.
I tried to look into the code where this could be implemented, but I  
somehow got lost in those 5 or 6
"needed_constraints" functions.

Well, I'll keep looking into this, but I don't seem to be good enough to  
solve this, I really hope this gets
solved somehow *g*. Everyone talks about leaving, but I find (after  
looking at Rails and others first) that
Nitro with all it's troubles, edges 'n failures is the only Framework I  
could ever breathe in. Since I'm not
yet making money with what I can, I rather watch Nitro rise instead of  
getting me strangled by any other
framework. Thank you all very much.

Kash
-- 
Feel the love
http://pinkjuice.com/pics/ruby.png



More information about the Nitro-general mailing list