8000 add json type support to mysql by oshai · Pull Request #84 · jasync-sql/jasync-sql · GitHub
[go: up one dir, main page]

Skip to content

add json type support to mysql #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DecoderRegistry(charset: Charset) {

return when (columnType) {
ColumnTypes.FIELD_TYPE_VARCHAR,
ColumnTypes.FIELD_TYPE_JSON,
ColumnTypes.FIELD_TYPE_ENUM -> this.stringDecoder
ColumnTypes.FIELD_TYPE_BLOB,
ColumnTypes.FIELD_TYPE_LONG_BLOB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ object ColumnTypes {

val FIELD_TYPE_YEAR = 13

val FIELD_TYPE_JSON = 245

val Mapping = mapOf(
FIELD_TYPE_BIT to "bit",
FIELD_TYPE_BLOB to "blob",
Expand Down Expand Up @@ -86,7 +88,8 @@ object ColumnTypes {
FIELD_TYPE_TINY_BLOB to "tiny_blob",
FIELD_TYPE_VAR_STRING to "var_string",
FIELD_TYPE_VARCHAR to "varchar",
FIELD_TYPE_YEAR to "year"
FIELD_TYPE_YEAR to "year",
FIELD_TYPE_JSON to "json"
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,22 @@ class QuerySpec : ConnectionHelper() {
}

@Test
fun `"connection" should "select from a large text column" `() {
fun `"connection" should "select from a json column" `() {

val create = "create temporary table bombs (id char(4), bomb mediumtext character set ascii)"
val create = "create temporary table jsons (id char(4), data json)"

val insert = """ insert bombs values
| ('bomb', repeat(' ',65536+16384+8192+4096+2048+1024+512+256+128)),
| ('good', repeat(' ',65536+16384+8192+4096+2048+1024+512+256+128-1))""".trimMargin("|")
val insert = """ insert jsons values
| ('json', '{"a": 1}')""".trimMargin("|")


withConnection { connection ->
executeQuery(connection, create)
executeQuery(connection, insert)
val result = executeQuery(connection, "select bomb from bombs").rows
val result = executeQuery(connection, "select data from jsons").rows

assertThat(result.size).isEqualTo(2)
assertThat(result.size).isEqualTo(1)

assertThat((result(0)("bomb") as String).length).isEqualTo(98176)
assertThat((result(1)("bomb") as String).length).isEqualTo(98175)
assertThat((result(0)("data"))).isEqualTo("""{"a": 1}""")
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class BinaryRowDecoderSpec {
}


fun createColumn(name: String, columnType: Int): ColumnDefinitionMessage {
private fun createColumn(name: String, columnType: Int): ColumnDefinitionMessage {
return ColumnDefinitionMessage(
"root",
"root",
Expand Down
0