def test_PRIMARY_KEY_type(self): col = Constraint("CONSTRAINT `symbol` PRIMARY KEY USING BTREE (`index_col_name1`,`index_col_name2`),") self.assertTrue(isinstance(col, PrimaryKey)) self.assertEqual(col.symbol, 'symbol') self.assertEqual(col.indextype, "USING BTREE") self.assertEqual(col.indexcols, ["index_col_name1", "index_col_name2"]) self.assertEqual(col.sql(flavor="sqlite"), 'PRIMARY KEY ("index_col_name1", "index_col_name2")') self.assertIsNone(col.index("tbl_name", flavor="sqlite"))
def test_UNIQUE_KEY(self): col = Constraint("UNIQUE KEY `index_name` (`index_col_name`),") self.assertTrue(isinstance(col, Index)) self.assertEqual(col.indexname, 'index_name') self.assertIsNone(col.indextype) self.assertEqual(col.indexcols, ["index_col_name"]) self.assertIsNotNone(col.unique) self.assertEqual(col.sql(flavor="sqlite"), 'UNIQUE ("index_col_name")') self.assertIsNone(col.index("tbl_name", flavor="sqlite"))
def test_INDEX_2_type(self): col = Constraint("INDEX `index_name` USING HASH (`index_col_name1`,`index_col_name2`),") self.assertTrue(isinstance(col, Index)) self.assertEqual(col.indexname, 'index_name') self.assertEqual(col.indextype, "USING HASH") self.assertEqual(col.indexcols, ["index_col_name1", "index_col_name2"]) self.assertIsNone(col.unique) self.assertEqual(col.index("tbl_name", flavor="sqlite"), 'CREATE INDEX "index_name" ON "tbl_name" ("index_col_name1", "index_col_name2")') self.assertIsNone(col.sql(flavor="sqlite"))
def test_KEY_type(self): col = Constraint("KEY `index_name` USING BTREE (`index_col_name`),") self.assertTrue(isinstance(col, Index)) self.assertEqual(col.indexname, 'index_name') self.assertEqual(col.indextype, "USING BTREE") self.assertEqual(col.indexcols, ["index_col_name"]) self.assertIsNone(col.unique) self.assertEqual(col.index("tbl_name", flavor="sqlite"), 'CREATE INDEX "index_name" ON "tbl_name" ("index_col_name")') self.assertIsNone(col.sql(flavor="sqlite"))