Home » Database » MDB2 » Bug #8359
Problem with NOT NULL / NULL when creating Table
Details
| Submitted | 2006-08-04 11:26 UTC |
|---|---|
| From | kaiser at unisolution dot de |
| Assigned | lsmith |
| Status | Closed |
| Package | MDB2 |
| PHP Version | 4.3.8 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-08-04 11:26 UTC] kaiser at unisolution dot de
Description:
------------
I am working with MS SQL Server right now, and there seems to be a Problem with NULL / NOT NULL when creating a Table.
in MS SQL you need to specify for each column that if NULL is allowed:
NOT NULL -> null values not allowed
NULL -> null values allowed
[nothing] -> null values NOT allowed, i don't know if it's like this with every version of SQL Server, but the version of SQL Server 2000 i work with right now marks a column a NOT NULL if its not specified.
The Problem now is, that MDB2 only adds a NOT NULL to the query is NULL is not allowed, but doesn't add anything if NULL should be allowed. Because of the SQL Server behaviour i described above, all columns are then specified as NOT NULL.
a quick fix i tried today was to overwrite the functions _getDeclaration, _getCLOBDeclaration of MDB2/Driver/Datatype/Common.php in MDB2/Driver/Datatype/MSSQL.php
and replace $notnull = (!empty($field['notnull'])) ? ' NOT NULL' : '';
by
$notnull = (!empty($field['notnull'])) ? ' NOT NULL' : ' NULL ';
in each of these functions. This fix worked for me, but maybe there is a better solution...