Replies: 1 comment 2 replies
-
|
Hi @mpgrill, I don't think this is likely a feature we will support. We feel it is better to have a single, consistent behavior for decoding records for SQLite, and if you deviate from that behavior, then it's on you to provide a localized solution like you did with your custom However, I think an even better solution here is to not use an enum at all for your domain. If you really do have an open ended enum that can have different cases on different devices, then an enum is probably not the best tool. Are you ever actually switching on the enum in your code? If not, then it could just be a struct FeatureKey: RawRepresentable, QueryBindable {
var rawValue: String
static let featureA = Self(rawValue: "featureA")
static let featureB = Self(rawValue: "featureB")
}This allows you to still reference features with a static dot-syntax such as And if you are switching on your |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @mbrandonw @stephencelis,
Thanks for the great work on SQLiteData!
Problem
When using
@FetchAllwith types conforming toQueryBindable, a single record with an invalid enum value causes the entire fetch to fail, returning zero results instead of partial results with invalid records skipped.Real-world scenario:
@FetchAllin main branch returns 0 records (instead of skipping unknown records)This is particularly problematic for:
Current Behavior
When the fetch encounters a record with
key = "featureC", theinit(decoder:)inQueryBindablethrows, and the entire fetch fails.Root Cause: QueryBindable Decoder
The issue occurs in the
init(decoder:)required byQueryDecodable:When this throws:
@FetchAllreturns empty arrayCurrent Workaround
We implemented a fallback pattern with an
.unknownsentinel case:QueryBindable Implementation
Codable Implementation (Secondary)
This works but requires:
.unknowncaseQueryBindableandCodableimplementations for every enumProposed Solutions
Option 1: Fetch-level Configuration
Option 2: Query Modifier
Option 3: Global Database Configuration
Questions
Use Cases
This feature would be valuable for:
Would love to hear thoughts on the best approach for this!
Beta Was this translation helpful? Give feedback.
All reactions