Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.2.2
-
Fix Version/s: 1.2.2
-
Component/s: Schema Files
-
Labels:None
-
Environment:Apache 2.2, PostgresSQL 8.4, Windows XP
Description
When generating models from db with doctrine 1.2.2, default with functions in database get evaluated and the value goes to the generated schema files thus cousing error on insert/update.
Example:
Table:
CREATE TABLE Usuario (
id SERIAL NOT NULL,
apelido CHARACTER VARYING(50) NOT NULL,
email CHARACTER VARYING(255) NOT NULL,
dtRegistro TIMESTAMP DEFAULT 'now()' NOT NULL,
idUsuarioSituacao INTEGER,
senha CHARACTER(32),
CONSTRAINT PK_Usuario PRIMARY KEY (id),
CONSTRAINT TUC_Usuario_1 UNIQUE (email)
)
Code to generate files:
$dManager = Doctrine_Manager::getInstance();
$dManager->setAttribute(Doctrine::ATTR_MODEL_LOADING,Doctrine::MODEL_LOADING_CONSERVATIVE);
$dManager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$dManager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_NONE);
$dManager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_NONE);
$dManager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$dManager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
$dManager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS);
Doctrine_Core::generateModelsFromDb('c:\temp', array('dbcon'), array('generateTableClasses' => true, 'classPrefix' => 'D'));
Resulting file:
abstract class DBaseUsuario extends Doctrine_Record
{
public function setTableDefinition()
}
The function now() for default value gets replaced by 'default' => '\'2010-06-04 11:10:12.078\'::timestamp without time zone',
as of now i dont know if this is a error from case modeling tool or doctrine, will close and do further testing.