Note that there are some explanatory texts on larger screens.

plurals
  1. PODoctrine unsigned validation error storing created_at
    text
    copied!<p>I'm having problems with the Timestampable functionality in Doctrine 1.2.2 and 1.2.3.</p> <p>The error I get on trying to save() my Record is:</p> <blockquote> <p>Uncaught exception 'Doctrine_Validator_Exception' with message 'Validation failed in class XXX 1 field had validation error: * 1 <strong>validator failed on created_at (unsigned)</strong> ' in ...</p> </blockquote> <p>I've created the relevant field in the MySQL table as:</p> <blockquote> <p><code>created_at</code> DATETIME NOT NULL,</p> </blockquote> <p>Then in setTableDefinition() I have:</p> <blockquote> <pre><code> $this-&gt;hasColumn('created_at', 'timestamp', null, array( 'type' =&gt; 'timestamp', 'fixed' =&gt; false, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; true, 'autoincrement' =&gt; false, )); </code></pre> </blockquote> <p>Which is taken straight from the output of generateModelsFromDb().</p> <p>And finally my setUp() looks like:</p> <blockquote> <pre><code>public function setUp() { parent::setUp(); $this-&gt;actAs('Timestampable', array( 'created' =&gt; array( 'name' =&gt; 'created_at', 'type' =&gt; 'timestamp', 'format' =&gt; 'Y-m-d H:i:s', 'disabled' =&gt; false, 'options' =&gt; array() ), 'updated' =&gt; array( 'disabled' =&gt; true ))); } </code></pre> </blockquote> <p>(I've tried not defining all of those fields for 'created', but I get the same problem.)</p> <p>I'm a bit stumped as to what I'm doing wrong - for one thing I can't see why Doctrine would be running any unsigned checks against a 'timestamp' datatype...</p> <p><strong>Updated</strong></p> <p>I'm on Debian Lenny (5.0.8) with MySQL (5.0.51a-24+lenny5O). The problem is occurring with Doctrine 1.2.3 and 1.2.2. I noticed that Doctrine's examples use TIMESTAMP MySQL columns rather than DATETIMEs, so I changed that and re-generated, but the problem still recurred. I also thought it might be a problem with the MySQL definition, so I ran generateSqlFromModels to get the right SQL, but that was fine too (DATETIME NOT NULL).</p> <p>I'm totally stumped - have logged a bug in Doctrine JIRA to see if I can get this figured out: <a href="http://www.doctrine-project.org/jira/browse/DC-965" rel="nofollow noreferrer">DC-965</a></p> <p>Any help gratefully received!</p> <p>Alex</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload