cvs: pear /MDB parser.php
| From: | Christian Dickmann | Date: | Fri, 23 Aug 2002 14:33:55 +0000 |
| Subject: | cvs: pear /MDB parser.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5907@lists.php.net to get a copy of this message | ||
dickmann Fri Aug 23 10:33:55 2002 EDT
Modified files:
/pear/MDB parser.php
Log:
fix validation of empty fields 2
Index: pear/MDB/parser.php
diff -u pear/MDB/parser.php:1.17 pear/MDB/parser.php:1.18
--- pear/MDB/parser.php:1.17 Fri Aug 23 10:13:24 2002
+++ pear/MDB/parser.php Fri Aug 23 10:33:54 2002
@@ -42,7 +42,7 @@
// | Author: Christian Dickmann <dickmann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: parser.php,v 1.17 2002/08/23 14:13:24 dickmann Exp $
+// $Id: parser.php,v 1.18 2002/08/23 14:33:54 dickmann Exp $
//
require_once "XML/Parser.php";
@@ -125,6 +125,9 @@
$this->field_name = '';
$this->field = array();
break;
+ case 'database-table-declaration-field-default':
+ $this->field['default'] == '';
+ break;
case 'database-table-declaration-index':
$this->index_name = '';
$this->index = array();
@@ -159,7 +162,9 @@
if (!isset($this->table['FIELDS'][$this->init_name])) {
$this->raiseError($xp, 'unkown field
"'.$this->init_name.'"');
};
- if (!$this->validateFieldValue($this->init_name, $this->init_value, $xp)) {
+ if ($this->init_value !== ''
+ && !$this->validateFieldValue($this->init_name, $this->init_value,
$xp))
+ {
$this->raiseError($xp, 'field "'.$this->init_name.'"
has wrong value');
};
$this->init['FIELDS'][$this->init_name] = $this->init_value;
@@ -249,7 +254,11 @@
};
$this->table['FIELDS'][$this->field_name] = $this->field;
if (isset($this->field['default'])) {
- if (!$this->validateFieldValue($this->field_name,
$this->field['default'], $xp)) {
+ if ($this->field['type'] == 'clob' ||
$this->field['type'] == 'blob') {
+ $this->raiseError($xp,
'"'.$this->field['type'].'"-fields are not allowed to have a
default value');
+ };
+ if ($this->field['default'] !== ''
+ && !$this->validateFieldValue($this->field_name,
$this->field['default'], $xp)) {
$this->raiseError($xp, 'default value of
"'.$this->field_name.'" is of wrong type');
};
};
@@ -342,9 +351,6 @@
{
if (!isset($this->table['FIELDS'][$field_name])) {
return;
- };
- if ($field_value === '') {
- return true;
};
$field_def = $this->table['FIELDS'][$field_name];
switch($field_def['type']) {