Re: MDB2_Schema : how to specify auto_increment ? (and other questions)

From: Date: Mon, 03 Oct 2005 19:58:30 +0000
Subject: Re: MDB2_Schema : how to specify auto_increment ? (and other questions)
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21211@lists.php.net to get a copy of this message
Lassiege Hugo wrote:
I try to use MDB2_Schema for alter, create and generate schema files. But there is no end user documentation so I try to ask my questions here. The dump operation succeed. I try with :
            'portability' => (MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL)
and             'portability' => (MDB2_PORTABILITY_ALL )
But when I try to reload the xml file, I encounter several problems : - the fields with auto_increment property lost this property. How can I keep auto_increment property ?
Its currently not supported. The next release will support it though. Right now all auto increment fields are converted to sequences.
- In my database, I had 'not null' fields but no default value. The generated files describe : in the first case <field>
    <name>idh</name>
    <type>integer</type>
</field> in the second case <field>
    <name>idh</name>
    <type>integer</type>
    <notnull>1</notnull>
</field> In the first case I lost "not null" properties. In the second case I can't reload with MDB2_schema, the message is :
    [userinfo] => Parser error: if field is "notnull", it needs a default value - No error - Byte: 198; Line: 17; Col: 100
Could you file a bug report with the exact version information for the package, the database used. Furthermore I need the create statement for the given table an the full result of the dump you got.
If I use : <default></default> (for empty) I get another errors :
    [userinfo] => [Last query: CREATE TABLE histo (idh INT DEFAULT NULL NOT NULL,dateCol DATETIME DEFAULT '0000-00-00 00:00:00',nom CHAR (50) DEFAULT NULL NOT NULL,type CHAR (1) DEFAULT 'D' NOT NULL,result CHAR (1) DEFAULT 'D' NOT NULL,perte INT DEFAULT 0 NOT NULL)]
[Native code: 1067] [Native message: Valeur par défaut invalide pour 'idh'] You can note the DEFAULT NULL NOT NULL that cause the problem. In conclusion, I don't know how to generate a correct schema files. Any idea ?
This is indeed a dilema. With setting: 'portability' => (MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL) This issue should not occur. But then there is no way to specify that you do infact want a column to be NULL and not an empty string. Maybe the underlying DTD needs to be extended. regards, Lukas

« previous php.pear.general (#21211) next »