mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Bool support
This commit is contained in:
1 parent
73e9d79e1a
commit
cf58123725
2 files changed
+16
No files matched your search
@@ -12,6 +12,13 @@ public protocol DBValue {
|
||||
func bindInStatement(statement: Statement, atIndex index:Int)
|
||||
}
|
||||
|
||||
extension Bool: DBValue {
|
||||
public func bindInStatement(statement: Statement, atIndex index: Int) {
|
||||
let code = sqlite3_bind_int(statement.cStatement, Int32(index), Int32(self ? 1 : 0))
|
||||
assert(code == SQLITE_OK)
|
||||
}
|
||||
}
|
||||
|
||||
extension Int: DBValue {
|
||||
public func bindInStatement(statement: Statement, atIndex index: Int) {
|
||||
let code = sqlite3_bind_int64(statement.cStatement, Int32(index), Int64(self))
|
||||
|
||||
@@ -13,6 +13,15 @@ public struct Row {
|
||||
self.statement = statement
|
||||
}
|
||||
|
||||
public func boolAtIndex(index: Int) -> Bool? {
|
||||
switch sqlite3_column_type(statement.cStatement, Int32(index)) {
|
||||
case SQLITE_NULL:
|
||||
return nil
|
||||
default:
|
||||
return sqlite3_column_int(statement.cStatement, Int32(index)) != 0
|
||||
}
|
||||
}
|
||||
|
||||
public func intAtIndex(index: Int) -> Int? {
|
||||
switch sqlite3_column_type(statement.cStatement, Int32(index)) {
|
||||
case SQLITE_NULL:
|
||||
|
||||
Reference in new issue
Block a user