Skip to content

Commit 5d8c044

Browse files
authored
Merge pull request #66 from eneko/master
Add support for MySQL FLOAT fields
2 parents 89ecddb + 7f6d91a commit 5d8c044

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/MySQL/Bind+Node.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension Bind {
2323
func cast<T>(_ buffer: UnsafeMutableRawPointer, _ type: T.Type) -> UnsafeMutablePointer<T> {
2424
return buffer.bindMemory(to: type, capacity: 1)
2525
}
26-
26+
2727

2828
func unwrap<T>(_ buffer: UnsafeMutableRawPointer, _ type: T.Type) -> T {
2929
return buffer.load(as: type)
@@ -97,6 +97,9 @@ extension Bind {
9797
case MYSQL_TYPE_DOUBLE:
9898
let double = unwrap(buffer, Double.self)
9999
return .number(.double(double))
100+
case MYSQL_TYPE_FLOAT:
101+
let float = unwrap(buffer, Float.self)
102+
return .number(.double(Double(float)))
100103
case MYSQL_TYPE_DATE:
101104
let time = unwrap(buffer, MYSQL_TIME.self)
102105
return .string("\(time.year.pad(4))-\(time.month.pad(2))-\(time.day.pad(2))")

0 commit comments

Comments
 (0)