Dear sqlobject-discuss,

  i have problem with one-to-one relation between two tables, below
  you can see the declarations in python as well as in postgres
  the problem is that a deletion of a unit record which exists in more
  plant unit records is possible.

  what did i make wrong?
  
  i have the following class definition:

class Unit(BaseObj):
        code = sqlobject.UnicodeCol(length=10, unique=1, notNone=1, 
alternateID=1)
        plantunit = sqlobject.SingleJoin("PlantUnit")
        
class PlantUnit(BaseObjCodeName):
        descr = sqlobject.UnicodeCol(default=None)
        unit = sqlobject.ForeignKey("Unit")
        type = sqlobject.UnicodeCol(length=1, notNone=1)
        survey = sqlobject.MultipleJoin("Survey")
        dimension = sqlobject.UnicodeCol(length=1, default='0')

  in postgres i have the following table definition:
CREATE TABLE unit
(
  id serial NOT NULL,
  is_deleted bool,
  code varchar(10) NOT NULL,
  CONSTRAINT unit_pkey PRIMARY KEY (id),
  CONSTRAINT unit_code_key UNIQUE (code)
) 
WITHOUT OIDS;
ALTER TABLE unit OWNER TO "PMSAdmin";

CREATE TABLE plant_unit
(
  id serial NOT NULL,
  code varchar(20) NOT NULL,
  name varchar(100) NOT NULL,
  is_deleted bool,
  descr text,
  unit_id int4,
  "type" varchar(1) NOT NULL,
  dimension varchar(1),
  CONSTRAINT plant_unit_pkey PRIMARY KEY (id),
  CONSTRAINT plant_unit_code_key UNIQUE (code)
) 
WITHOUT OIDS;
ALTER TABLE plant_unit OWNER TO "PMSAdmin";



-- 
Best regards,
 Ivan Horvath
 Chief Programmer

Anyone who has never made a mistake has never tried anything new.

/Albert Einstein/



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to