summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--adodb-datadict.inc.php35
-rw-r--r--datadict/datadict-mysql.inc.php2
-rw-r--r--datadict/datadict-postgres.inc.php3
-rw-r--r--datadict/datadict-sqlite.inc.php5
-rw-r--r--drivers/adodb-sqlite.inc.php1
-rw-r--r--drivers/adodb-sqlite3.inc.php1
6 files changed, 39 insertions, 8 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) {
diff --git a/datadict/datadict-mysql.inc.php b/datadict/datadict-mysql.inc.php
index 640fb87a..5ae33b1d 100644
--- a/datadict/datadict-mysql.inc.php
+++ b/datadict/datadict-mysql.inc.php
@@ -24,6 +24,8 @@ class ADODB2_mysql extends ADODB_DataDict {
var $dropIndex = 'DROP INDEX %s ON %s';
var $renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s'; // needs column-definition!
+ public $blobAllowsNotNull = true;
+
function MetaType($t,$len=-1,$fieldobj=false)
{
diff --git a/datadict/datadict-postgres.inc.php b/datadict/datadict-postgres.inc.php
index 8fcb5712..68bdeddc 100644
--- a/datadict/datadict-postgres.inc.php
+++ b/datadict/datadict-postgres.inc.php
@@ -25,6 +25,9 @@ class ADODB2_postgres extends ADODB_DataDict {
var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
var $dropTable = 'DROP TABLE %s CASCADE';
+ public $blobAllowsDefaultValue = true;
+ public $blobAllowsNotNull = true;
+
function MetaType($t,$len=-1,$fieldobj=false)
{
if (is_object($t)) {
diff --git a/datadict/datadict-sqlite.inc.php b/datadict/datadict-sqlite.inc.php
index 44b949c9..52c031ca 100644
--- a/datadict/datadict-sqlite.inc.php
+++ b/datadict/datadict-sqlite.inc.php
@@ -25,8 +25,9 @@ class ADODB2_sqlite extends ADODB_DataDict {
var $dropIndex = 'DROP INDEX IF EXISTS %s';
var $renameTable = 'ALTER TABLE %s RENAME TO %s';
-
-
+ public $blobAllowsDefaultValue = true;
+ public $blobAllowsNotNull = true;
+
function ActualType($meta)
{
switch(strtoupper($meta)) {
diff --git a/drivers/adodb-sqlite.inc.php b/drivers/adodb-sqlite.inc.php
index 7d86a9ae..8c0426b3 100644
--- a/drivers/adodb-sqlite.inc.php
+++ b/drivers/adodb-sqlite.inc.php
@@ -22,6 +22,7 @@ if (!defined('ADODB_DIR')) die();
class ADODB_sqlite extends ADOConnection {
var $databaseType = "sqlite";
+ var $dataProvider = "sqlite";
var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $_errorNo = 0;
diff --git a/drivers/adodb-sqlite3.inc.php b/drivers/adodb-sqlite3.inc.php
index d73ff62c..f4660d95 100644
--- a/drivers/adodb-sqlite3.inc.php
+++ b/drivers/adodb-sqlite3.inc.php
@@ -22,6 +22,7 @@ if (!defined('ADODB_DIR')) die();
class ADODB_sqlite3 extends ADOConnection {
var $databaseType = "sqlite3";
+ var $dataProvider = "sqlite";
var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $_errorNo = 0;