diff options
| author | Damien Regad <dregad@mantisbt.org> | 2013-09-20 00:24:24 +0200 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2013-09-20 00:24:24 +0200 |
| commit | 85c5412fb7018c296b018859db1d0c8c13d91568 (patch) | |
| tree | 4d0fd2f87944dacfb28c04f3d77f501bb5d68d88 /datadict | |
| parent | 66823f33c419d2e0ba707af95e63d39d202eaed0 (diff) | |
| download | adodb-85c5412fb7018c296b018859db1d0c8c13d91568.tar.gz adodb-85c5412fb7018c296b018859db1d0c8c13d91568.tar.bz2 adodb-85c5412fb7018c296b018859db1d0c8c13d91568.zip | |
PostgreSQL: AlterColumnSQL don't remove default NULL value
The preg_replace statement was doing a global replace of 'NULL' by '',
ignoring the fact that a column can be 'DEFAULT NULL', causing the
function to generate incorrect SQL.
Diffstat (limited to 'datadict')
| -rw-r--r-- | datadict/datadict-postgres.inc.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/datadict/datadict-postgres.inc.php b/datadict/datadict-postgres.inc.php index 888d642a..7b0ddb07 100644 --- a/datadict/datadict-postgres.inc.php +++ b/datadict/datadict-postgres.inc.php @@ -199,7 +199,10 @@ class ADODB2_postgres extends ADODB_DataDict { // explicitly ask a column to be null using $flds else if ($set_null = preg_match('/NULL/i',$v)) { // if they didn't specify not null, see if they explicitely asked for null - $v = preg_replace('/\sNULL/i','',$v); + // Lookbehind pattern covers the case 'fieldname NULL datatype DEFAULT NULL' + // only the first NULL should be removed, not the one specifying + // the default value + $v = preg_replace('/(?<!DEFAULT)\sNULL/i','',$v); } if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) { |
