Esempio n. 1
0
    def test_single_column(self):
        sql = ("CREATE TABLE `example_table` (\n" +
               "  `the_data` longtext COLLATE utf8mb4_unicode_ci NOT NULL\n" +
               ") ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 " +
               "COLLATE=utf8mb4_unicode_ci COMMENT='hi mum';")

        assert parse_create_table(sql) == {
            "the_data": "longtext COLLATE utf8mb4_unicode_ci NOT NULL"
        }
Esempio n. 2
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'
        }
    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'
        }
Esempio n. 4
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',
        }
Esempio n. 5
0
    def test_large_normalish_table(self):
        sql = (
            "CREATE TABLE `example` (\n" +
            "  `id` int(11) NOT NULL AUTO_INCREMENT,\n" +
            "  `varchary` varchar(255) NOT NULL,\n" +
            "  `texty` longtext NOT NULL,\n" +
            "  `inty` int(11) DEFAULT NULL,\n" +
            "  `datetimey` datetime NOT NULL,\n" + "  PRIMARY KEY (`id`),\n" +
            "  KEY `example_abcdef` (`varchary`),\n" +
            "  KEY `example_123456` (`inty`)\n" +
            "  CONSTRAINT `example_constraint` FOREIGN KEY (`id`) " +
            "REFERENCES `other` (`id`)\n" +
            ") ENGINE=InnoDB AUTO_INCREMENT=999999 DEFAULT CHARSET=utf8mb4 " +
            "ROW_FORMAT=COMPRESSED\n")

        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",
        }
    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',
        }