def test_create_sql_with_unique_constraint(self): table = Table("users") table.add_column("id", "integer") table.add_column("name", "string") table.add_constraint("name", "unique", ["name"]) table.set_primary_key("id") sql = 'CREATE TABLE "users" ("id" INTEGER NOT NULL, "name" VARCHAR NOT NULL, UNIQUE(name))' self.platform.constraintize(table.get_added_constraints()) self.assertEqual(self.platform.compile_create_sql(table), [sql])
def test_create_sql_with_multiple_unique_constraint(self): table = Table("users") table.add_column("id", "integer") table.add_column("email", "string") table.add_column("name", "string") table.add_constraint("name", "unique", ["name", "email"]) table.set_primary_key("id") sql = 'CREATE TABLE "users" (id INTEGER PRIMARY KEY, email VARCHAR, name VARCHAR, UNIQUE(name, email))' self.platform.constraintize(table.get_added_constraints()) self.assertEqual(self.platform.compile_create_sql(table), sql)