Commits

and...@69d324d9-c39d-4fdc-8679-7745eae9e2c8  committed 10ddc1b

Well, all but rename column works, cause MySQL is annoying.

  • Participants
  • Parent commits 692869f

Comments (0)

Files changed (2)

         
         qn = connection.ops.quote_name
         
-        params = (qn(table_namee), qn(old), qn(new))
-        return ['ALTER TABLE %s CHANGE COLUMN %s %s;' % params]
+        params = (qn(table_name), qn(old), qn(new))
+        self.execute('ALTER TABLE %s CHANGE COLUMN %s %s;' % params)
 
 
     def rename_table(self, old_table_name, table_name):
         # It needs to take at least 2 args
         self.assertRaises(TypeError, db.create_table)
         self.assertRaises(TypeError, db.create_table, "test1")
-        # Empty tables (i.e. no columns) are fine
-        db.create_table("test1", [])
+        # Empty tables (i.e. no columns) are not fine, so make at least 1
+        db.create_table("test1", [("col", "text")])
         db.commit_transaction()
         # And should exist
         cursor.execute("SELECT * FROM test1")
             db.delete_table("nottheretest1")
             self.fail("Non-existent table could be deleted!")
         except:
+            pass
+    
+    def test_rename(self):
+        """
+        Test column renaming
+        """
+        cursor = connection.cursor()
+        db.create_table("test2", [("spam", "text")])
+        db.commit_transaction()
+        # Make sure we can select the column
+        cursor.execute("SELECT spam FROM test2")
+        # Rename it
+        db.rename_column("test2", "spam", "eggs")
+        cursor.execute("SELECT eggs FROM test2")
+        try:
+            cursor.execute("SELECT spam FROM test2")
+            self.fail("Just-renamed column could be selected!")
+        except:
             pass