diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/SQLServerDialect.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/SQLServerDialect.kt index 14d242e385..5d12fb3d25 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/SQLServerDialect.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/SQLServerDialect.kt @@ -312,13 +312,7 @@ open class SQLServerDialect : VendorDialect(dialectName, SQLServerDataTypeProvid appendIfNotNull(" AUTHORIZATION ", schema.authorization) } - override fun dropSchema(schema: Schema, cascade: Boolean): String = buildString { - append("DROP SCHEMA ", schema.identifier) - - if (cascade) { - append(" CASCADE") - } - } + override fun dropSchema(schema: Schema, cascade: Boolean): String = "DROP SCHEMA ${schema.identifier}" override fun createIndex(index: Index): String { if (index.functions != null) { diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/SchemaTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/SchemaTests.kt index c298f381c5..9667585124 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/SchemaTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/SchemaTests.kt @@ -56,6 +56,20 @@ class SchemaTests : DatabaseTestsBase() { } } + @Test + fun testDropSchemaWithCascade() { + withDb { + if (currentDialect.supportsCreateSchema) { + val schema = Schema("TEST_SCHEMA") + SchemaUtils.createSchema(schema) + assertTrue(schema.exists()) + + SchemaUtils.dropSchema(schema, cascade = true) + assertFalse(schema.exists()) + } + } + } + @Test fun `table references table with same name in other database in mysql`() { withDb(listOf(TestDB.MYSQL, TestDB.MARIADB)) {