Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions SwiftData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ public struct SwiftData {
if sqlite3_column_type(statement, index) == SQLITE_NULL {
return nil
}
return Int(sqlite3_column_int(statement, index))
return NSNumber(longLong: sqlite3_column_int64(statement, index))
case "CHARACTER(20)", "VARCHAR(255)", "VARYING CHARACTER(255)", "NCHAR(55)", "NATIVE CHARACTER", "NVARCHAR(100)", "TEXT", "CLOB":
let text = UnsafePointer<Int8>(sqlite3_column_text(statement, index))
return String.fromCString(text)
Expand Down Expand Up @@ -1141,7 +1141,22 @@ public struct SwiftData {
:returns: An Optional Int corresponding to the apprioriate column value. Will be nil if: the column name does not exist, the value cannot be cast as a Int, or the value is NULL
*/
public func asInt() -> Int? {
return value as? Int
if let num = value as? NSNumber {
return num.longValue
}
return nil
}

/**
Return the column value as an Int64

:returns: An Optional Int64 corresponding to the apprioriate column value. Will be nil if: the column name does not exist, the value cannot be cast as a Int64, or the value is NULL
*/
public func asInt64() -> Int64? {
if let num = value as? NSNumber {
return num.longLongValue
}
return nil
}

/**
Expand Down Expand Up @@ -1705,4 +1720,4 @@ extension SwiftData.SDError {

}

public typealias SD = SwiftData
public typealias SD = SwiftData