Skip to content

Commit

Permalink
Add JSON MySQL support.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuawright11 committed Jan 24, 2021
1 parent 1b4b81b commit 19bf5d5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Alchemy/SQL/Database/MySQL/MySQL+DatabaseRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ extension MySQLData {
case .float, .decimal, .double:
let value = DatabaseValue.double(try validateNil(self.double))
return DatabaseField(column: column, value: value)
case .json:
guard var buffer = self.buffer else {
return DatabaseField(column: column, value: .json(nil))
}

let data = buffer.readData(length: buffer.writerIndex)
return DatabaseField(column: column, value: .json(data))
default:
let errorMessage = "Couldn't parse a `\(self.type)` from column "
+ "'\(column)'. That MySQL datatype isn't supported, yet."
Expand Down

0 comments on commit 19bf5d5

Please sign in to comment.