cvs: pear /DB_DBA DBA_Sql.php /DB_DBA/tests test_sql.php
| From: | Brent Cook | Date: | Wed, 10 Jul 2002 04:13:55 +0000 |
| Subject: | cvs: pear /DB_DBA DBA_Sql.php /DB_DBA/tests test_sql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4999@lists.php.net to get a copy of this message | ||
busterb Wed Jul 10 00:13:55 2002 EDT
Modified files:
/pear/DB_DBA DBA_Sql.php
/pear/DB_DBA/tests test_sql.php
Log:
preparing to understand 'constraint', understands 'check', putting off
'sequence' for now
Index: pear/DB_DBA/DBA_Sql.php
diff -u pear/DB_DBA/DBA_Sql.php:1.9 pear/DB_DBA/DBA_Sql.php:1.10
--- pear/DB_DBA/DBA_Sql.php:1.9 Tue Jul 9 23:34:46 2002
+++ pear/DB_DBA/DBA_Sql.php Wed Jul 10 00:13:55 2002
@@ -18,7 +18,7 @@
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
//
-// $Id: DBA_Sql.php,v 1.9 2002/07/10 03:34:46 busterb Exp $
+// $Id: DBA_Sql.php,v 1.10 2002/07/10 04:13:55 busterb Exp $
//
require_once "PEAR.php";
@@ -137,14 +137,14 @@
exit;
} else {
while ($token && ($token != ')')) {
- $fieldName = Sql::getToken();
+ $token = Sql::getToken();
- if ($fieldName == ')') {
+ if ($token == ')') {
// we must have had a trailing comma in the field list
- $token = $fieldName;
break;
}
+ $fieldName = $token;
$fieldType = Sql::getTokenL();
$table[$fieldName]['type'] = $fieldType;
$token = Sql::getTokenL();
@@ -180,11 +180,7 @@
}
} elseif (Sql::isStringType($fieldType)) {
if ($token == '(') {
- $table[$fieldName]['size'] = Sql::getToken();
- if (Sql::getToken() != ')') {
- return PEAR::raiseError(
- "expected ) on $fieldName, $fieldType");
- }
+ $table[$fieldName]['size'] = strtok(')');
$token = Sql::getTokenL();
}
} elseif (Sql::isSetType($fieldType)) {
@@ -254,11 +250,15 @@
if (Sql::getToken() != '(') {
PEAR::raiseError('expecting (');
} else {
- $table[$fieldName]['size']=Sql::getToken();
- if (Sql::getToken() != ')') {
- PEAR::raiseError('expecting )');
- }
+ $table[$fieldName]['size']=strtok(')');
}
+ }
+ break;
+ case 'check':
+ if (Sql::getToken() != '(') {
+ PEAR::raiseError('expecting (');
+ } else {
+ $table[$fieldName]['check']=strtok(')');
}
}
// grab the next option
Index: pear/DB_DBA/tests/test_sql.php
diff -u pear/DB_DBA/tests/test_sql.php:1.8 pear/DB_DBA/tests/test_sql.php:1.9
--- pear/DB_DBA/tests/test_sql.php:1.8 Tue Jul 9 23:34:46 2002
+++ pear/DB_DBA/tests/test_sql.php Wed Jul 10 00:13:55 2002
@@ -20,7 +20,7 @@
// | Author: Brent Cook <busterb@mail.utexas.edu> |
// +----------------------------------------------------------------------+
//
-// $Id: test_sql.php,v 1.8 2002/07/10 03:34:46 busterb Exp $
+// $Id: test_sql.php,v 1.9 2002/07/10 04:13:55 busterb Exp $
//
// test functionality of the sql parser
@@ -61,7 +61,7 @@
CONSTRAINT production UNIQUE(date_prod)
)",
"CREATE TABLE distributors (
- did DECIMAL(3) PRIMARY KEY DEFAULT NEXTVAL('serial'),
+ did DECIMAL(3) PRIMARY KEY Auto_Increment,
name VARCHAR(40) NOT NULL CHECK (name <> '')
CONSTRAINT con1 CHECK (did > 100 AND name > '')
)",