Skip to content

Commit

Permalink
fix: Removing ModelFieldType.int64
Browse files Browse the repository at this point in the history
  • Loading branch information
lawmicha committed Nov 27, 2023
1 parent b622589 commit 98d4759
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public enum ModelFieldType {

case string
case int
case int64
case double
case date
case dateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension Model {
return Fatal.preconditionFailure("Could not turn into json object from \(value)")
}
}
case .string, .int, .int64, .double, .timestamp, .bool:
case .string, .int, .double, .timestamp, .bool:
input[name] = value
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension ModelSyncMetadata {

definition.fields(
.id(),
.field(keys.lastSync, is: .optional, ofType: .int64)
.field(keys.lastSync, is: .optional, ofType: .int)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension MutationSyncMetadata {
definition.fields(
.id(),
.field(sync.deleted, is: .required, ofType: .bool),
.field(sync.lastChangedAt, is: .required, ofType: .int64),
.field(sync.lastChangedAt, is: .required, ofType: .int),
.field(sync.version, is: .required, ofType: .int)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension MutationSyncMetadataMigration {
definition.fields(
.id(),
.field(sync.deleted, is: .required, ofType: .bool),
.field(sync.lastChangedAt, is: .required, ofType: .int64),
.field(sync.lastChangedAt, is: .required, ofType: .int),
.field(sync.version, is: .required, ofType: .int)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension ModelField: SQLColumn {
switch type {
case .string, .enum, .date, .dateTime, .time, .model:
return .text
case .int, .int64, .bool, .timestamp:
case .int, .bool, .timestamp:
return .integer
case .double:
return .real
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public struct SQLiteModelValueConverter: ModelValueConverter {
case .string:
return value as? String
case .int:
return value as? Int
case .int64:
return value as? Int64
if let intValue = value as? Int {
return intValue
}
if let int64Value = value as? Int64 {
return int64Value
}
return nil
case .double:
return value as? Double
case .date, .dateTime, .time:
Expand Down Expand Up @@ -70,7 +74,7 @@ public struct SQLiteModelValueConverter: ModelValueConverter {
switch fieldType {
case .string, .date, .dateTime, .time:
return value as? String
case .int, .int64:
case .int:
return value as? Int64
case .double:
return value as? Double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ extension ModelSchema {
value2Optional: value2Optional)
.sortComparator(sortOrder: sortOrder)
case .int, .timestamp:
guard let value1Optional = value1 as? Int?, let value2Optional = value2 as? Int? else {
return false
if let value1Optional = value1 as? Int?, let value2Optional = value2 as? Int? {
return ModelValueCompare(value1Optional: value1Optional,
value2Optional: value2Optional)
.sortComparator(sortOrder: sortOrder)
}
return ModelValueCompare(value1Optional: value1Optional,
value2Optional: value2Optional)
.sortComparator(sortOrder: sortOrder)
case .int64:
guard let value1Optional = value1 as? Int64?, let value2Optional = value2 as? Int64? else {
return false

if let value1Optional = value1 as? Int64?, let value2Optional = value2 as? Int64? {
return ModelValueCompare(value1Optional: value1Optional,
value2Optional: value2Optional)
.sortComparator(sortOrder: sortOrder)
}
return ModelValueCompare(value1Optional: value1Optional,
value2Optional: value2Optional)
.sortComparator(sortOrder: sortOrder)

return false
case .double:
guard let value1Optional = value1 as? Double?, let value2Optional = value2 as? Double? else {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,17 @@ extension ModelSchema {
return false
}
case .int:
guard let value1Optional = value1 as? Int?, let value2Optional = value2 as? Int? else {
return false
}
if !compare(value1Optional, value2Optional) {
return false
}
case .int64:
guard let value1Optional = value1 as? Int64?, let value2Optional = value2 as? Int64? else {
return false
if let value1Optional = value1 as? Int?, let value2Optional = value2 as? Int? {
if !compare(value1Optional, value2Optional) {
return false
}
}
if !compare(value1Optional, value2Optional) {
return false
if let value1Optional = value1 as? Int64?, let value2Optional = value2 as? Int64? {
if !compare(value1Optional, value2Optional) {
return false
}
}
return false
case .double:
guard let value1Optional = value1 as? Double?, let value2Optional = value2 as? Double? else {
return false
Expand Down

0 comments on commit 98d4759

Please sign in to comment.