cvs: pear /MDB2_Schema/MDB2/Schema Parser.php Validate.php
| From: | Lukas Smith | Date: | Sun, 20 Aug 2006 20:47:32 +0000 |
| Subject: | cvs: pear /MDB2_Schema/MDB2/Schema Parser.php Validate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41769@lists.php.net to get a copy of this message | ||
lsmith Sun Aug 20 20:47:32 2006 UTC
Modified files:
/pear/MDB2_Schema/MDB2/Schema Parser.php Validate.php
Log:
- fixed index handling
- the actual assignments of valid structures should happen inside the Parser
http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/MDB2/Schema/Parser.php?r1=1.46&r2=1.47&diff_format=u
Index: pear/MDB2_Schema/MDB2/Schema/Parser.php
diff -u pear/MDB2_Schema/MDB2/Schema/Parser.php:1.46 pear/MDB2_Schema/MDB2/Schema/Parser.php:1.47
--- pear/MDB2_Schema/MDB2/Schema/Parser.php:1.46 Sat Aug 19 12:33:35 2006
+++ pear/MDB2_Schema/MDB2/Schema/Parser.php Sun Aug 20 20:47:32 2006
@@ -42,7 +42,7 @@
// | Author: Christian Dickmann <dickmann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Parser.php,v 1.46 2006/08/19 12:33:35 lsmith Exp $
+// $Id: Parser.php,v 1.47 2006/08/20 20:47:32 lsmith Exp $
//
require_once 'XML/Parser.php';
@@ -176,7 +176,7 @@
/* Definition */
case 'database-table':
$this->table_name = '';
- $this->table = array();
+ $this->table = array('fields' => array(), 'indexes' =>
array());
break;
case 'database-table-declaration-field':
$this->field_name = '';
@@ -187,7 +187,7 @@
break;
case 'database-table-declaration-index':
$this->index_name = '';
- $this->index = array();
+ $this->index = array('fields' => array());
break;
case 'database-sequence':
$this->seq_name = '';
@@ -295,6 +295,8 @@
$result = $this->val->validateIndexField($this->index['fields'],
$this->field, $this->field_name);
if (PEAR::isError($result)) {
$this->raiseError($result->getMessage(), 0, $xp, $result->getCode());
+ } else {
+ $this->index['fields'][$this->field_name] = $this->field;
}
break;
http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/MDB2/Schema/Validate.php?r1=1.15&r2=1.16&diff_format=u
Index: pear/MDB2_Schema/MDB2/Schema/Validate.php
diff -u pear/MDB2_Schema/MDB2/Schema/Validate.php:1.15
pear/MDB2_Schema/MDB2/Schema/Validate.php:1.16
--- pear/MDB2_Schema/MDB2/Schema/Validate.php:1.15 Sun Aug 20 19:52:05 2006
+++ pear/MDB2_Schema/MDB2/Schema/Validate.php Sun Aug 20 20:47:32 2006
@@ -43,7 +43,7 @@
// | Author: Igor Feghali <ifeghali@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Validate.php,v 1.15 2006/08/20 19:52:05 lsmith Exp $
+// $Id: Validate.php,v 1.16 2006/08/20 20:47:32 lsmith Exp $
//
/**
@@ -406,18 +406,22 @@
*/
function validateIndexField(&$index_fields, &$field, $field_name)
{
+ if (isset($index_fields[$field_name])) {
+ return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE_INDEX_FIELD_EXISTS,
+ 'index field "'.$field_name.'" already exists');
+ }
if (!$field_name) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE_NO_INDEX_FIELD_NAME,
'the index-field-name is required');
}
if (!empty($field['sorting'])
- && $field['sorting'] !== 'ascending' &&
$field['sorting'] !== 'descending') {
+ && $field['sorting'] !== 'ascending' &&
$field['sorting'] !== 'descending'
+ ) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE_INVALID_SORT,
'sorting type unknown');
} else {
$field['sorting'] = 'ascending';
}
- $index['fields'][$field_name] = $field;
return true;
}