]> git.mjollnir.org Git - moodle.git/commitdiff
Now Oracle naming of objects introspects to avoid duplicates. MDL-7376
authorstronk7 <stronk7>
Sat, 27 Jan 2007 22:11:04 +0000 (22:11 +0000)
committerstronk7 <stronk7>
Sat, 27 Jan 2007 22:11:04 +0000 (22:11 +0000)
lib/xmldb/classes/generators/oci8po/oci8po.class.php

index 41d5144dc17eb789460c3facfb19517bfb88300f..2c040d7bb1bf3ee33774998049816a8f07b0b8f5 100644 (file)
@@ -527,6 +527,37 @@ class XMLDBoci8po extends XMLDBgenerator {
         return $sequencename;
     }
 
+    /**
+     * Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg)
+     * return if such name is currently in use (true) or no (false)
+     * (invoked from getNameForObject()
+     */
+    function isNameInUse($object_name, $type) {
+        switch($type) {
+            case 'ix':
+            case 'uix':
+            case 'seq':
+            case 'trg':
+                if ($check = get_records_sql("SELECT object_name 
+                                              FROM user_objects 
+                                              WHERE lower(object_name) = '" . strtolower($object_name) . "'")) {
+                    return true;
+                }
+                break;
+            case 'pk':
+            case 'uk':
+            case 'fk':
+            case 'ck':
+                if ($check = get_records_sql("SELECT constraint_name 
+                                              FROM user_constraints
+                                              WHERE lower(constraint_name) = '" . strtolower($object_name) . "'")) {
+                    return true;
+                }
+                break;
+        }
+        return false; //No name in use found
+    }
+
     /**
      * Returns an array of reserved words (lowercase) for this DB
      */