Skip to content

Commit

Permalink
Merge pull request #66 from eneko/master
Browse files Browse the repository at this point in the history
Add support for MySQL FLOAT fields
  • Loading branch information
tanner0101 authored Dec 2, 2016
2 parents 89ecddb + 7f6d91a commit 5d8c044
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/MySQL/Bind+Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Bind {
func cast<T>(_ buffer: UnsafeMutableRawPointer, _ type: T.Type) -> UnsafeMutablePointer<T> {
return buffer.bindMemory(to: type, capacity: 1)
}


func unwrap<T>(_ buffer: UnsafeMutableRawPointer, _ type: T.Type) -> T {
return buffer.load(as: type)
Expand Down Expand Up @@ -97,6 +97,9 @@ extension Bind {
case MYSQL_TYPE_DOUBLE:
let double = unwrap(buffer, Double.self)
return .number(.double(double))
case MYSQL_TYPE_FLOAT:
let float = unwrap(buffer, Float.self)
return .number(.double(Double(float)))
case MYSQL_TYPE_DATE:
let time = unwrap(buffer, MYSQL_TIME.self)
return .string("\(time.year.pad(4))-\(time.month.pad(2))-\(time.day.pad(2))")
Expand Down

0 comments on commit 5d8c044

Please sign in to comment.