I'm currently testing Propel 2. I know that they aren't fully stable jet.
My issue is, that I try to insert data into a table. So far so good.
But I get this Exception:
This is the code for inserting:
$db = new CoreCountry();
try{
$db->setIdent($ident)
->setIso2($iso2)
->setIso3($iso3)
->setTranslation($translation)
->setId(null)
->save();
An this is the table description:
CREATE TABLE core_country (
id integer NOT NULL,
ident character varying(64),
iso2 character varying(2),
iso3 character varying(3),
translation text
);
CREATE SEQUENCE core_country_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE lab.core_country_id_seq OWNER TO postgres;
ALTER SEQUENCE core_country_id_seq OWNED BY core_country.id;
ALTER TABLE ONLY core_country ALTER COLUMN id SET DEFAULT nextval('core_country_id_seq'::regclass);
ALTER TABLE ONLY core_country ADD CONSTRAINT core_country_ident_key UNIQUE (ident);
ALTER TABLE ONLY core_country ADD CONSTRAINT core_country_iso2_key UNIQUE (iso2);
ALTER TABLE ONLY core_country ADD CONSTRAINT core_country_iso3_key UNIQUE (iso3);
ALTER TABLE ONLY core_country ADD CONSTRAINT core_country_pkey PRIMARY KEY (id);
I removed the not null statement, but it was readded automatically by the db.
I also inserted an empty string into the setId method, but that returned that you are not allowed to add anything to an autoincrement field.
Please help.
Please always post your schema.xml so we're seeing your real table description.
The error says
FEHLER: NULL-Wert in Spalte »id« verletzt Not-Null-Constraint
You have set id
to null
right before the ->save()
call. So it's pretty obvious that you shouldn't pass null
, set a right value or make it auto-increment and drop the ->setId()
call.