From 4215e41ecb57743b45128dfc873847a679282da5 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 9 Sep 2007 16:28:16 +0000 Subject: [PATCH] Extending getCheckConstraintsFromDB() to support a new parameter used to filter what field in the table we want to know its check constraints --- .../classes/generators/XMLDBGenerator.class.php | 9 +++++++++ .../classes/generators/mssql/mssql.class.php | 6 ++++-- .../classes/generators/mysql/mysql.class.php | 6 ++++-- .../classes/generators/oci8po/oci8po.class.php | 6 ++++-- .../generators/postgres7/postgres7.class.php | 15 +++++++++++++-- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/xmldb/classes/generators/XMLDBGenerator.class.php b/lib/xmldb/classes/generators/XMLDBGenerator.class.php index 75084d73ce..8534db9589 100644 --- a/lib/xmldb/classes/generators/XMLDBGenerator.class.php +++ b/lib/xmldb/classes/generators/XMLDBGenerator.class.php @@ -1193,6 +1193,15 @@ class XMLDBgenerator { return array('Code to drop one default goes to getDropDefaultSQL()'); } + /** + * Given one XMLDBTable and one optional XMLDBField, return one array with all the check + * constrainst found for that table (or field). Must exist for each DB supported. + * (usually invoked from find_check_constraint_name) + */ + function getCheckConstraintsFromDB($xmldb_table, $xmldb_field=null) { + return array('Code to fetch check constraints goes to getCheckConstraintsFromDB()'); + } + /** * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add its default * (usually invoked from getModifyDefaultSQL() diff --git a/lib/xmldb/classes/generators/mssql/mssql.class.php b/lib/xmldb/classes/generators/mssql/mssql.class.php index 808324d593..4552deb261 100644 --- a/lib/xmldb/classes/generators/mssql/mssql.class.php +++ b/lib/xmldb/classes/generators/mssql/mssql.class.php @@ -444,12 +444,14 @@ class XMLDBmssql extends XMLDBgenerator { } /** - * Given one XMLDBTable returns one array with all the check constrainsts + * Given one XMLDBTable returns one array with all the check constrainsts * in the table (fetched from DB) + * Optionally the function allows one xmldb_field to be specified in + * order to return only the check constraints belonging to one field. * Each element contains the name of the constraint and its description * If no check constraints are found, returns an empty array */ - function getCheckConstraintsFromDB($xmldb_table) { + function getCheckConstraintsFromDB($xmldb_table, $xmldb_field = null) { $results = array(); diff --git a/lib/xmldb/classes/generators/mysql/mysql.class.php b/lib/xmldb/classes/generators/mysql/mysql.class.php index 149e0288ec..98c39cae34 100644 --- a/lib/xmldb/classes/generators/mysql/mysql.class.php +++ b/lib/xmldb/classes/generators/mysql/mysql.class.php @@ -247,14 +247,16 @@ class XMLDBmysql extends XMLDBGenerator { } /** - * Given one XMLDBTable returns one array with all the check constrainsts + * Given one XMLDBTable returns one array with all the check constrainsts * in the table (fetched from DB) + * Optionally the function allows one xmldb_field to be specified in + * order to return only the check constraints belonging to one field. * Each element contains the name of the constraint and its description * If no check constraints are found, returns an empty array * MySQL doesn't have check constraints in this implementation, but * we return them based on the enum fields in the table */ - function getCheckConstraintsFromDB($xmldb_table) { + function getCheckConstraintsFromDB($xmldb_table, $xmldb_field = null) { global $db; diff --git a/lib/xmldb/classes/generators/oci8po/oci8po.class.php b/lib/xmldb/classes/generators/oci8po/oci8po.class.php index 4600422399..694d6003d5 100644 --- a/lib/xmldb/classes/generators/oci8po/oci8po.class.php +++ b/lib/xmldb/classes/generators/oci8po/oci8po.class.php @@ -477,12 +477,14 @@ class XMLDBoci8po extends XMLDBgenerator { } /** - * Given one XMLDBTable returns one array with all the check constrainsts + * Given one XMLDBTable returns one array with all the check constrainsts * in the table (fetched from DB) + * Optionally the function allows one xmldb_field to be specified in + * order to return only the check constraints belonging to one field. * Each element contains the name of the constraint and its description * If no check constraints are found, returns an empty array */ - function getCheckConstraintsFromDB($xmldb_table) { + function getCheckConstraintsFromDB($xmldb_table, $xmldb_field = null) { $results = array(); diff --git a/lib/xmldb/classes/generators/postgres7/postgres7.class.php b/lib/xmldb/classes/generators/postgres7/postgres7.class.php index 7e75a9f1c2..8f7fb6a033 100644 --- a/lib/xmldb/classes/generators/postgres7/postgres7.class.php +++ b/lib/xmldb/classes/generators/postgres7/postgres7.class.php @@ -305,6 +305,15 @@ class XMLDBpostgres7 extends XMLDBgenerator { $notnullchanged = false; } + /// TODO: Some combinations like + /// TODO: integer->integer + /// TODO: integer->text + /// TODO: number->text + /// TODO: text->text + /// TODO: do not require the use of temp columns, because PG 8.0 supports them automatically + /// TODO: with a simple "alter table zzz alter column yyy type new specs" + /// TODO: Must be implemented that way. Eloy 09/2007 + /// If the type or the precision or the decimals have changed, then we need to: /// - create one temp column with the new specs /// - fill the new column with the values from the old one (casting if needed) @@ -422,12 +431,14 @@ class XMLDBpostgres7 extends XMLDBgenerator { } /** - * Given one XMLDBTable returns one array with all the check constrainsts + * Given one XMLDBTable returns one array with all the check constrainsts * in the table (fetched from DB) + * Optionally the function allows one xmldb_field to be specified in + * order to return only the check constraints belonging to one field. * Each element contains the name of the constraint and its description * If no check constraints are found, returns an empty array */ - function getCheckConstraintsFromDB($xmldb_table) { + function getCheckConstraintsFromDB($xmldb_table, $xmldb_field = null) { $results = array(); -- 2.39.5