Home » Database » DB_DataObject » Bug #1595
options generator_include_regex & generator_exclude_regex
Details
| Submitted | 2004-06-09 18:57 UTC |
|---|---|
| From | stephane dot gully at libertysurf dot fr |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 4.3.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-06-09 18:57 UTC] stephane dot gully at libertysurf dot fr
Description:
------------
There is an interesant feature into the new DB_DataObject release :
> * new options to filter generation of classes
> generator_include_regex = /foo_.*/i
> generator_exclude_regex = /tmp_.*/i
I've a prb with these new options ..., I set :
generator_include_regex = /mi_.*/i
generator_exclude_regex = /gacl_.*/i
because I want to include only mi_* table names (I think it's not necessary to specify generator_exclude_regex for me but the prb is not here.)
Then I generate the dataobjects, and I get these warnings :
Notice: Undefined index: gacl_acl in /home/kerphi/lib/eclipse/workspace/src/lib/pear/DB/DataObject/Generator.php* on line 248
Warning: Invalid argument supplied for foreach() in /home/kerphi/lib/eclipse/workspace/src/lib/pear/DB/DataObject/Generator.php* on line 270
Unfortunately gacl_* dataobjects classes are also generated :(
So maybe it's a bug ?
Stephane
[2004-06-09 20:36 UTC] stephane dot gully at libertysurf dot fr
Hello again,
I've written a little patch to fix this bug.
Stephane
Index: Generator.php
===================================================================
RCS file: /repository/pear/DB_DataObject/DataObject/Generator.php,v
retrieving revision 1.64
diff -u -r1.64 Generator.php
--- Generator.php 2 Jun 2004 15:10:39 -0000 1.64
+++ Generator.php 9 Jun 2004 20:43:40 -0000
@@ -158,6 +158,9 @@
$this->tables = $__DB->getListOf('tables');
+ // declare a temporary table to be filled with matching tables names
+ $tmp_table = array();
+
foreach($this->tables as $table) {
if (isset($options['generator_include_regex']) &&
!preg_match($options['generator_include_regex'],$table)) {
@@ -166,6 +169,10 @@
preg_match($options['generator_exclude_regex'],$table)) {
continue;
}
+
+ // we find a matching table, juste store it into a temporary array
+ $tmp_table[] = $table;
+
$defs = $__DB->tableInfo($table);
if (is_a($defs,'PEAR_Error')) {
echo $defs->toString();
@@ -178,6 +185,10 @@
}
}
}
+
+ // the temporary table array is now the right one (tables names matching with regex expressions have been removed)
+ $this->tables = $tmp_table;
+
//print_r($this->_definitions);
}