コード例 #1
0
    def test_single_column(self):
        sql = dedent("""\
        CREATE TABLE `example_table` (
          `the_data` longtext COLLATE utf8mb4_unicode_ci NOT NULL
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='hi mum';
        """)  # noqa

        assert parse_create_table(sql) == {
            'the_data': 'longtext COLLATE utf8mb4_unicode_ci NOT NULL'
        }
コード例 #2
0
    def test_large_normalish_table(self):
        sql = dedent("""\
        CREATE TABLE `example` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `varchary` varchar(255) NOT NULL,
          `texty` longtext NOT NULL,
          `inty` int(11) DEFAULT NULL,
          `datetimey` datetime NOT NULL,
          PRIMARY KEY (`id`),
          KEY `example_abcdef` (`varchary`),
          KEY `example_123456` (`inty`)
          CONSTRAINT `example_constraint` FOREIGN KEY (`id`) REFERENCES `other` (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=999999 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED
        """)  # noqa

        assert parse_create_table(sql) == {
            'id': 'int(11) NOT NULL AUTO_INCREMENT',
            'varchary': 'varchar(255) NOT NULL',
            'texty': 'longtext NOT NULL',
            'inty': 'int(11) DEFAULT NULL',
            'datetimey': 'datetime NOT NULL',
        }