Commit d2906855 authored by Morton Jonuschat's avatar Morton Jonuschat Committed by Anja Leichsenring
Browse files

[BUGFIX] ADOdb: support NOT NULL/DEFAULT field attributes on BLOB/TEXT fields

Instead of globally disallowing NOT NULL and DEFAULT field attributes
make these attributes configurable per DBMS system.

Data dictionaries for PostgreSQL and MySQL are adjusted to match
the supported options.

Resolves: #67442
Releases: master
Change-Id: Ic0fb7a07ef4db9fc854489165ebc079382c2f011
Reviewed-on: http://review.typo3.org/40398


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent d1e9309a
......@@ -12,7 +12,7 @@ The currently used ADOdb version is 5.19 [1]_.
Our changes
===========
This is a list of changes we made in ADOdb and may must re-applied if EXT:adodb is
This is a list of changes we made in ADOdb that must re-applied if EXT:adodb is
updated to upstream.
- ADOdb: Invalid override method signature (48034_) (Solved in 5.20-dev [2]_)
......@@ -22,8 +22,10 @@ updated to upstream.
- ADOdb: mssqlnative driver fails to create sequences (66678_)
- ADOdb: mssqlnative driver is not properly initialized (66830_)
- ADOdb: mssqlnative driver does not properly define the port (63070_)
- ADOdb: Allow setting NOT NULL/DEFAULT on blob and text columns (67442_) (Upstream pull request: [3]_)
.. [2] https://github.com/ADOdb/ADOdb/commit/85f05a98974ea85ecae943faf230a27afdbaa746
.. [3] https://github.com/ADOdb/ADOdb/pull/118
.. _48034: https://forge.typo3.org/issues/48034
.. _61738: https://forge.typo3.org/issues/61738
.. _63659: https://forge.typo3.org/issues/63659
......@@ -31,6 +33,7 @@ updated to upstream.
.. _66678: https://forge.typo3.org/issues/66678
.. _66830: https://forge.typo3.org/issues/66830
.. _63070: https://forge.typo3.org/issues/63070
.. _67442: https://forge.typo3.org/issues/67442
Diff
......
......@@ -297,3 +297,56 @@ index b10d555..21cfc69 100644
//if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
diff --git a/adodb-datadict.inc.php b/adodb-datadict.inc.php
index b8b881e..f2b17f3 100644
--- a/adodb-datadict.inc.php
+++ b/adodb-datadict.inc.php
@@ -178,6 +178,8 @@ class ADODB_DataDict {
var $autoIncrement = false;
var $dataProvider;
var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql
+ var $blobNotNull = false; // dbms supports NOT NULL for BLOB/TEXT columns
+ var $blobDefaults = false; // dbms supports defaults for BLOB/TEXT columns
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 editting.
@@ -717,12 +719,12 @@ class ADODB_DataDict {
$ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
- if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls
+ if (($ty == 'X' || $ty == 'X2' || $ty == 'B') && $this->blobNotNull !== true) $fnotnull = false; // some blob types do not accept nulls
if ($fprimary) $pkey[] = $fname;
// some databases do not allow blobs to have defaults
- if ($ty == 'X') $fdefault = false;
+ if ($ty == 'X' && $this->blobDefaults !== true) $fdefault = false;
// build list of indexes
if ($findex != '') {
diff --git a/datadict/datadict-mysql.inc.php b/datadict/datadict-mysql.inc.php
index 773aa0c..701fa66 100644
--- a/datadict/datadict-mysql.inc.php
+++ b/datadict/datadict-mysql.inc.php
@@ -21,6 +21,7 @@ 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!
+ var $blobNotNull = true;
function MetaType($t,$len=-1,$fieldobj=false)
{
diff --git a/datadict/datadict-postgres.inc.php b/datadict/datadict-postgres.inc.php
index 965314d..3556825 100644
--- a/datadict/datadict-postgres.inc.php
+++ b/datadict/datadict-postgres.inc.php
@@ -22,6 +22,8 @@ class ADODB2_postgres extends ADODB_DataDict {
var $quote = '"';
var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
var $dropTable = 'DROP TABLE %s CASCADE';
+ var $blobNotNull = true;
+ var $blobDefaults = true;
function MetaType($t,$len=-1,$fieldobj=false)
{
......@@ -178,6 +178,8 @@ class ADODB_DataDict {
var $autoIncrement = false;
var $dataProvider;
var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql
var $blobNotNull = false; // dbms supports NOT NULL for BLOB/TEXT columns
var $blobDefaults = false; // dbms supports defaults for BLOB/TEXT columns
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 editting.
......@@ -717,12 +719,12 @@ class ADODB_DataDict {
$ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls
if (($ty == 'X' || $ty == 'X2' || $ty == 'B') && $this->blobNotNull !== true) $fnotnull = false; // some blob types do not accept nulls
if ($fprimary) $pkey[] = $fname;
// some databases do not allow blobs to have defaults
if ($ty == 'X') $fdefault = false;
if ($ty == 'X' && $this->blobDefaults !== true) $fdefault = false;
// build list of indexes
if ($findex != '') {
......
......@@ -21,6 +21,7 @@ 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!
var $blobNotNull = true;
function MetaType($t,$len=-1,$fieldobj=false)
{
......
......@@ -22,6 +22,8 @@ class ADODB2_postgres extends ADODB_DataDict {
var $quote = '"';
var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
var $dropTable = 'DROP TABLE %s CASCADE';
var $blobNotNull = true;
var $blobDefaults = true;
function MetaType($t,$len=-1,$fieldobj=false)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment