Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #8359 Problem with NOT NULL / NULL when creating Table
Submitted: 2006-08-04 11:26 UTC
From: kaiser at unisolution dot de Assigned: lsmith
Status: Closed Package: MDB2 (version 1.1.0)
PHP Version: 4.3.8 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-08-04 11:26 UTC] kaiser at unisolution dot de (Josh)
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...

Comments

 [2006-08-04 12:25 UTC] lsmith (Lukas Smith)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2006-08-05 17:23 UTC] lsmith (Lukas Smith)
this bug required changes to the core MDB2 package