Skip to content

Commit

Permalink
Change string length check to use codePointCount (#745, #743)
Browse files Browse the repository at this point in the history
Test enabled
  • Loading branch information
Tapac committed Jan 3, 2020
1 parent f27b6c0 commit 53ff362
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum class TestDB(val connection: () -> String, val driver: String, val user: St
val port = System.getProperty("exposed.test.mysql.port") ?: System.getProperty("exposed.test.mysql8.port")
host?.let { dockerHost ->
"jdbc:mysql://$dockerHost:$port/testdb?useSSL=false"
} ?: "jdbc:mysql:mxj://localhost:12345/testdb1?createDatabaseIfNotExist=true&server.initialize-user=false&user=root&password="
} ?: "jdbc:mysql:mxj://localhost:12345/testdb1?createDatabaseIfNotExist=true&characterEncoding=UTF-8&server.initialize-user=false&user=root&password="
},
driver = "com.mysql.jdbc.Driver",
beforeConnection = { System.setProperty(Files.USE_TEST_DIR, java.lang.Boolean.TRUE!!.toString()); Files().cleanTestDir(); Unit },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.jetbrains.exposed.sql.tests.currentDialectTest
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.vendors.*
import org.junit.Assert.assertThat
import org.junit.Ignore
import org.junit.Test
import java.math.BigDecimal
import java.util.*
Expand Down Expand Up @@ -1462,17 +1461,17 @@ class DMLTests : DatabaseTestsBase() {
}
}

// https://github.com/JetBrains/Exposed/issues/743
// need to configure the MySQL server with character_set_server=utf8mb4?
// https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html
@Ignore
@Test fun testInsertEmojis() {
val table = object : Table("tmp") {
val emoji = varchar("emoji", 16)
}
val emojis = "\uD83D\uDC68\uD83C\uDFFF\u200D\uD83D\uDC69\uD83C\uDFFF\u200D\uD83D\uDC67\uD83C\uDFFF\u200D\uD83D\uDC66\uD83C\uDFFF"

withTables(listOf(TestDB.SQLITE, TestDB.H2, TestDB.H2_MYSQL, TestDB.POSTGRESQL), table) {
withTables(listOf(TestDB.H2, TestDB.H2_MYSQL), table) {
val isOldMySQL = currentDialectTest is MysqlDialect && db.isVersionCovers(BigDecimal("5.5"))
if (isOldMySQL) {
exec("ALTER TABLE ${table.nameInDatabaseCase()} DEFAULT CHARSET utf8mb4, MODIFY emoji VARCHAR(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
}
table.insert {
it[table.emoji] = emojis
}
Expand Down

0 comments on commit 53ff362

Please sign in to comment.