[1.7.1] Can't insert new records using PostgreSQL #837

Closed
zergu opened this Issue Mar 4, 2014 · 6 comments

Projects

None yet

5 participants

@zergu

Hi, after upgrading Propel from 1.7.0 to 1.7.1 in my Symfony 2.4 project regenerating base object classes removes that part of code:

-        if (null === $this->id) {
-            try {
-                $stmt = $con->query("SELECT nextval('event_id_seq')");
-                $row = $stmt->fetch(PDO::FETCH_NUM);
-                $this->id = $row[0];
-            } catch (Exception $e) {
-                throw new PropelException('Unable to get sequence id.', $e);
-            }
-        }

And this leads to:

Not null violation: 7 ERROR: null value in column "id" violates not-null constraint]

Downgrading to 1.7.0 helps.

@staabm
Propel member

Whats the schema of your table?

@zergu
    <table name="event">
        <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
        <column name="event_type_id" type="INTEGER" required="false"/>
        <column name="patient_id" type="INTEGER" required="true"/>
        <column name="doctor_id" type="INTEGER" required="true"/>
        <column name="application_id" type="INTEGER" required="true"/>
        <column name="start_at" type="TIMESTAMP" required="true"/>
        <column name="duration" type="SMALLINT" required="true"/>
        <column name="main_disease_id" type="INTEGER" required="false"/>
        <column name="inquiry" type="VARCHAR" size="16000" required="false"/>
        <column name="status_preasens" type="VARCHAR" size="16000" required="false"/>
        <column name="description" type="VARCHAR" size="16000" required="false"/>
        <column name="recommendation" type="VARCHAR" size="16000" required="false"/>
        <column name="medical_leave_issued" type="BOOLEAN" required="true" defaultValue="false"/>
        <column name="medical_leave_note" type="VARCHAR" size="2000" required="false"/>
        <column name="cancel_description" type="VARCHAR" size="8000" required="false"/>
        <column name="is_reservation" type="BOOLEAN" required="true" defaultValue="true"/>
        <column name="patient_note" type="VARCHAR" size="2000" required="false"/>
        <column name="income" type="DOUBLE" required="true" defaultValue="0"/>
        <column name="office_id" type="INTEGER" required="false"/>
        <foreign-key foreignTable="application" onDelete="CASCADE">
            <reference local="application_id" foreign="id"/>
        </foreign-key>
        <foreign-key foreignTable="event_type" onDelete="SET NULL">
            <reference local="event_type_id" foreign="id"/>
        </foreign-key>
        <foreign-key foreignTable="patient" onDelete="CASCADE">
            <reference local="patient_id" foreign="id"/>
        </foreign-key>
        <foreign-key foreignTable="doctor" onDelete="SET NULL">
            <reference local="doctor_id" foreign="id"/>
        </foreign-key>
        <foreign-key foreignTable="disease" onDelete="SET NULL">
            <reference local="main_disease_id" foreign="id"/>
        </foreign-key>
        <foreign-key foreignTable="office" onDelete="SET NULL">
            <reference local="office_id" foreign="id"/>
        </foreign-key>
        <behavior name="timestampable"/>
    </table>
@stood

I have tested with your schema and sf2.4 and it's good for me. Plz delete the 'Base' class and regenerate your classes and delete your cache too

@willdurand
Propel member

@stood is right.

@willdurand willdurand closed this Mar 16, 2014
@docteurklein

@zergu I think I have a similar problem.

When cascade-saving a job which has many jobAddresses, the jobAddress.job_id is not marked as a modified column. And even if I mark it manually as modified, its internal value is null.

@docteurklein

mmh. I may be wrong (and sorry to pollute a closed issue from someone else :) ). I'll open a new one with my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment