]> git.mjollnir.org Git - moodle.git/commitdiff
Extending getCheckConstraintsFromDB() to support a new parameter
authorstronk7 <stronk7>
Sun, 9 Sep 2007 16:28:16 +0000 (16:28 +0000)
committerstronk7 <stronk7>
Sun, 9 Sep 2007 16:28:16 +0000 (16:28 +0000)
used to filter what field in the table we want to know
its check constraints

lib/xmldb/classes/generators/XMLDBGenerator.class.php
lib/xmldb/classes/generators/mssql/mssql.class.php
lib/xmldb/classes/generators/mysql/mysql.class.php
lib/xmldb/classes/generators/oci8po/oci8po.class.php
lib/xmldb/classes/generators/postgres7/postgres7.class.php

index 75084d73ceae8ed8ebf8ec5eed8d912a2535366b..8534db95899b4d324340b887128c553848890d77 100644 (file)
@@ -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()
index 808324d593320743a623f8141d7d457e63a0a398..4552deb261fa3427b1a31e77ed1523d87f0889b9 100644 (file)
@@ -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();
 
index 149e0288ec4f2705da8ecf0b16f421fe107e430f..98c39cae341b4b724bfc3aaa2458dc37dc8cad56 100644 (file)
@@ -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;
 
index 460042239948a0251a718bfa953e74f22ed85281..694d6003d5d6481eb550f350d0af00a8b9d141ab 100644 (file)
@@ -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();
 
index 7e75a9f1c21a3403c41f14d57719c800d458fa15..8f7fb6a033bf492e79b43c4a0b3eec59f148626e 100644 (file)
@@ -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();