diff options
Diffstat (limited to 'adodb-datadict.inc.php')
| -rw-r--r-- | adodb-datadict.inc.php | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/adodb-datadict.inc.php b/adodb-datadict.inc.php index 1a96eff6..fc5f932b 100644 --- a/adodb-datadict.inc.php +++ b/adodb-datadict.inc.php @@ -183,6 +183,19 @@ class ADODB_DataDict { var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob /// in other words, we use a text area for editing. + /* + * Indicates whether a BLOB/CLOB field will allow a NOT NULL setting + * The type is whatever is matched to an X or X2 or B type. We must + * explicitly set the value in the driver to switch the behaviour on + */ + public $blobAllowsNotNull; + /* + * Indicates whether a BLOB/CLOB field will allow a DEFAULT set + * The type is whatever is matched to an X or X2 or B type. We must + * explicitly set the value in the driver to switch the behaviour on + */ + public $blobAllowsDefaultValue; + function GetCommentSQL($table,$col) { return false; @@ -567,7 +580,7 @@ class ADODB_DataDict { list($lines,$pkey,$idxs) = $this->_GenFields($flds, true); // genfields can return FALSE at times if ($lines == null) $lines = array(); - + $taboptions = $this->_Options($tableoptions); $tabname = $this->TableName ($tabname); $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); @@ -644,7 +657,6 @@ class ADODB_DataDict { $idxs = array(); foreach($flds as $fld) { $fld = _array_change_key_case($fld); - $fname = false; $fdefault = false; $fautoinc = false; @@ -726,12 +738,22 @@ class ADODB_DataDict { $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec, $fOptions); - if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls + if (($ty == 'X' || $ty == 'X2' || $ty == 'B') && !$this->blobAllowsNotNull) + /* + * some blob types do not accept nulls, so we override the + * previously defined value + */ + $fnotnull = false; - if ($fprimary) $pkey[] = $fname; + if ($fprimary) + $pkey[] = $fname; - // some databases do not allow blobs to have defaults - if ($ty == 'X') $fdefault = false; + if (($ty == 'X' || $ty == 'X2' || $ty == 'B') && !$this->blobAllowsDefaultValue) + /* + * some databases do not allow blobs to have defaults, so we + * override the previously defined value + */ + $fdefault = false; // build list of indexes if ($findex != '') { @@ -901,6 +923,7 @@ class ADODB_DataDict { return $sql; } } + $s = "CREATE TABLE $tabname (\n"; $s .= implode(",\n", $lines); if (sizeof($pkey)>0) { |
