Skip to content

Commit

Permalink
fix fields with default value (can be NULL)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeef committed Sep 22, 2024
1 parent 1a21982 commit 8ae491c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions MMEX/Models/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ struct Transaction: ExportableEntity {
var deletedTime: String?
var followUpId: Int64?
var toTransAmount: Double?
var color: Int64
var color: Int64?

init(
id: Int64, accountId: Int64, toAccountId: Int64? = nil, payeeId: Int64,
transCode: Transcode, transAmount: Double, status: TransactionStatus,
transactionNumber: String? = nil, notes: String? = nil, categId: Int64? = nil,
transDate: String?, lastUpdatedTime: String? = nil, deletedTime: String? = nil,
followUpId: Int64? = nil, toTransAmount: Double? = nil, color: Int64 = -1
followUpId: Int64? = nil, toTransAmount: Double? = nil, color: Int64? = nil
) {
self.id = id
self.accountId = accountId
Expand Down
2 changes: 1 addition & 1 deletion MMEX/Repositories/InfotableRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension InfotableRepository {

// load specific keys into a dictionary
func load(for keys: [InfoKey]) -> [InfoKey: Infotable] {
guard let db else { return [:] }
if db == nil { return [:] }
var results: [InfoKey: Infotable] = [:]
for key in keys {
if let info = pluck(
Expand Down
4 changes: 2 additions & 2 deletions MMEX/Repositories/PayeeRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PayeeRepository: RepositoryProtocol {
static let col_website = SQLite.Expression<String?>("WEBSITE")
static let col_notes = SQLite.Expression<String?>("NOTES")
static let col_active = SQLite.Expression<Int?>("ACTIVE")
static let col_pattern = SQLite.Expression<String>("PATTERN")
static let col_pattern = SQLite.Expression<String?>("PATTERN")

static func selectQuery(from table: SQLite.Table) -> SQLite.Table {
return table.select(
Expand All @@ -62,7 +62,7 @@ class PayeeRepository: RepositoryProtocol {
website : row[col_website],
notes : row[col_notes],
active : row[col_active] ?? 1,
pattern : row[col_pattern]
pattern : row[col_pattern] ?? ""
)
}

Expand Down
2 changes: 1 addition & 1 deletion MMEX/Repositories/TransactionRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TransactionRepository: RepositoryProtocol {
static let col_deletedTime = SQLite.Expression<String?>("DELETEDTIME")
static let col_followUpId = SQLite.Expression<Int64?>("FOLLOWUPID")
static let col_toTransAmount = SQLite.Expression<Double?>("TOTRANSAMOUNT")
static let col_color = SQLite.Expression<Int64>("COLOR")
static let col_color = SQLite.Expression<Int64?>("COLOR")

// cast NUMERIC to REAL
static let cast_transAmount = cast(col_transAmount) as SQLite.Expression<Double>
Expand Down

0 comments on commit 8ae491c

Please sign in to comment.