From 15a0ffc8f098a65dd34a943611cedfbb94620096 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 11 Oct 2009 21:52:40 +0000 Subject: [PATCH] MDL-20349 find_sequence_name() is out. No need to use it anymore. --- admin/xmldb/actions/test/test.class.php | 27 +++++-------------------- lib/ddl/database_manager.php | 19 ----------------- lib/ddl/oracle_sql_generator.php | 2 +- lib/ddl/simpletest/testddl.php | 19 ----------------- lib/deprecatedlib.php | 12 ----------- 5 files changed, 6 insertions(+), 73 deletions(-) diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php index 8e59a4fa2c..216794646a 100644 --- a/admin/xmldb/actions/test/test.class.php +++ b/admin/xmldb/actions/test/test.class.php @@ -946,24 +946,7 @@ class test extends XMLDBAction { $tests['rename table'] = $test; } - /// 45th test. Getting the PK sequence name for one table - if ($test->status) { - $table->setName('newnameforthetable'); - $test = new stdClass; - $test->sql = array($dbman->find_sequence_name($table)); - $test->status = $dbman->find_sequence_name($table); - if (!$test->status) { - if (!$test->error = $DB->get_last_error()) { //If no db errors, result is ok. Just the driver doesn't support this - $test->sql = array('Not needed for this DB. Correct.'); - $test->status = true; - } else { - $test->error .= "\n" . $e; - } - } - $tests['find sequence name'] = $test; - } - - /// 46th test. Inserting TEXT contents + /// 45th test. Inserting TEXT contents $textlib = textlib_get_instance(); if ($test->status) { $test = new stdClass; @@ -1002,7 +985,7 @@ class test extends XMLDBAction { $tests['insert record '. $textlen . ' cc. (text)'] = $test; } - /// 47th test. Inserting BINARY contents + /// 46th test. Inserting BINARY contents if ($test->status) { $test = new stdClass; $test->status = false; @@ -1031,7 +1014,7 @@ class test extends XMLDBAction { $tests['insert record '. $textlen . ' bytes (binary)'] = $test; } - /// 48th test. $DB->update_record with TEXT and BINARY contents + /// 47th test. $DB->update_record with TEXT and BINARY contents if ($test->status) { $test = new stdClass; $test->status = false; @@ -1071,7 +1054,7 @@ class test extends XMLDBAction { $tests['update record '. $textlen . ' cc. (text) and ' . $imglen . ' bytes (binary)'] = $test; } - /// 49th test. $DB->set_field with TEXT contents + /// 48th test. $DB->set_field with TEXT contents if ($test->status) { $test = new stdClass; $test->status = false; @@ -1101,7 +1084,7 @@ class test extends XMLDBAction { $tests['set field '. $textlen . ' cc. (text)'] = $test; } - /// 50th test. $DB->set_field with BINARY contents + /// 49th test. $DB->set_field with BINARY contents if ($test->status) { $test = new stdClass; $test->status = false; diff --git a/lib/ddl/database_manager.php b/lib/ddl/database_manager.php index 60a469a4d3..6411b87814 100644 --- a/lib/ddl/database_manager.php +++ b/lib/ddl/database_manager.php @@ -311,25 +311,6 @@ class database_manager { } } - - /** - * Given one xmldb_table, the function returns the name of its sequence in DB - * - * @param xmldb_table the table to be searched - * @return string sequence name of false - */ - public function find_sequence_name(xmldb_table $xmldb_table) { - if (!$this->table_exists($xmldb_table)) { - throw new ddl_table_missing_exception($xmldb_table->getName()); - } - - $sequencename = false; - - $sequencename = $this->generator->getSequenceFromDB($xmldb_table); - - return $sequencename; - } - /** * This function will delete all tables found in XMLDB file from db * diff --git a/lib/ddl/oracle_sql_generator.php b/lib/ddl/oracle_sql_generator.php index 87f908800f..f285308517 100644 --- a/lib/ddl/oracle_sql_generator.php +++ b/lib/ddl/oracle_sql_generator.php @@ -86,7 +86,7 @@ class oracle_sql_generator extends sql_generator { $value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}'); $value++; - $seqname = $this->mdb->get_manager()->find_sequence_name($xmldb_table); + $seqname = $this->getSequenceFromDB($xmldb_table); if (!$seqname) { /// Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method diff --git a/lib/ddl/simpletest/testddl.php b/lib/ddl/simpletest/testddl.php index 87c1bead72..eae22e3293 100755 --- a/lib/ddl/simpletest/testddl.php +++ b/lib/ddl/simpletest/testddl.php @@ -1183,25 +1183,6 @@ class ddl_test extends UnitTestCase { $this->assertTrue(!empty($result)); } - public function testFindSequenceName() { - $dbman = $this->tdb->get_manager(); - - // give nonexistent table param - $table = new xmldb_table("nonexistenttable"); - try { - $dbman->find_sequence_name($table); - $this->assertTrue(false); - } catch (Exception $e) { - $this->assertTrue($e instanceof moodle_exception); - } - - // Give existing and valid table param - $table = $this->create_deftable('test_table0'); -//TODO: this returns stuff depending on db internals - // $this->assertEqual(false, $dbman->find_sequence_name($table)); - - } - public function testDeleteTablesFromXmldbFile() { global $CFG; $dbman = $this->tdb->get_manager(); diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 41468d5198..4db9b34a84 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -686,18 +686,6 @@ function find_key_name($table, $xmldb_key) { return $DB->get_manager()->find_key_name($table, $xmldb_key); } -/** - * @deprecated - * @global object - * @param string $table - * @return bool - */ -function find_sequence_name($table) { - global $DB; - debugging('Deprecated ddllib function used!'); - return $DB->get_manager()->find_sequence_name($table); -} - /** * @deprecated * @global object -- 2.39.5