Data adopts StatementColumnConvertible

This commit is contained in:
Gwendal Roué committed 2017-08-29 19:27:47 +02:00
1 parent d472c1696d
commit 2785e69fc1
2 files changed
+13 -1

No files matched your search

+12 -1
View File
@@ -1,7 +1,18 @@
import Foundation
#if SWIFT_PACKAGE
import CSQLite
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
/// Data is convertible to and from DatabaseValue.
extension Data : DatabaseValueConvertible {
extension Data : DatabaseValueConvertible, StatementColumnConvertible {
public init(sqliteStatement: SQLiteStatement, index: Int32) {
let bytes = unsafeBitCast(sqlite3_column_blob(sqliteStatement, Int32(index)), to: UnsafePointer<UInt8>.self)
let count = Int(sqlite3_column_bytes(sqliteStatement, Int32(index)))
self.init(bytes: bytes, count: count) // copy bytes
}
/// Returns a value that can be stored in the database.
public var databaseValue: DatabaseValue {
// SQLite cant' store zero-length blobs.
+1
View File
@@ -18,6 +18,7 @@ GRDB 2.0
- [ ] New concrete cursors
- [ ] check performance improvements
- [ ] document
- [ ] Test new adoption of StatementColumnConvertible by Data. Add support for NSData if possible/needed.
Not sure