Exemplo n.º 1
0
 def test_single_column_comment_case_insensitive(self):
     """Test REGEX_TABLE_COMMENT lowercase (comment '*')"""
     table = """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL comment 'this is your first name',`last_name` varchar(100) NOT NULL,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"""
     (sql, count) = REGEX_TABLE_COMMENT.subn('', table)
     self.assertEqual(count, 1)
     self.assertEqual(sql, """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL ,`last_name` varchar(100) NOT NULL,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8""")
Exemplo n.º 2
0
 def test_multiple_column_comment_with_table_comment(self):
     """Test REGEX_TABLE_COMMENT multiple column comments and the Table comment"""
     table = """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL COMMENT 'this is your first name',`last_name` varchar(100) NOT NULL COMMENT='this is your last name',`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB COMMENT 'table comment' DEFAULT CHARSET=utf8"""
     (sql, count) = REGEX_TABLE_COMMENT.subn('', table)
     self.assertEqual(count, 3)
     self.assertEqual(sql, """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL ,`last_name` varchar(100) NOT NULL ,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB  DEFAULT CHARSET=utf8""")
Exemplo n.º 3
0
 def test_no_comments(self):
     """Test REGEX_TABLE_COMMENT no comments"""
     table = """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL,`last_name` varchar(100) NOT NULL,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"""
     (sql, count) = REGEX_TABLE_COMMENT.subn('', table)
     self.assertEqual(count, 0)
     self.assertEqual(sql, table)
Exemplo n.º 4
0
 def test_single_column_comment_equals_seperator_with_spaces(self):
     """Test REGEX_TABLE_COMMENT = seperator surrounded by spaces (COMMENT = '*')"""
     table = """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL COMMENT = 'this is your first name',`last_name` varchar(100) NOT NULL,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"""
     (sql, count) = REGEX_TABLE_COMMENT.subn('', table)
     self.assertEqual(count, 1)
     self.assertEqual(sql, """CREATE TABLE `person` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL ,`last_name` varchar(100) NOT NULL,`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8""")