Replies: 1 comment 6 replies
-
|
@ahti Thanks for flagging this. After mulling it over we think that our decoding is overly lenient. We've pushed a PR exploring a "strict" mode here, which will throw on type mismatch, allowing you to wrap your One thing to consider is that this is only as flexible as SQLite's very limited type affinity, so you wouldn't be able to use this trick to distinguish a Wanna take it for a spin and let us know what you think? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on building a prototype reimplementation of an apps model layer using sqlite-data (just the local db part), aiming for compatibility with the existing schema. It's going rather well overall, except for one column in one table: This column does not have a type annotation in the schema, and the type of the value varies per row between String, Int and Double based on runtime configuration.
The current version of the app uses (through some abstraction)
sqlite3_column_typeand switches over the result to determine what type to decode, so the type just becomes whatever was bound when the row was inserted, put in Int, get back an Int, put in String, get back a String, no matter how number-y the string might look or whatever.With sqlite-data/structured-queries, there doesn't seem to be a way to replicate this behavior, or at least I can't seem to find one.
Would you be open to accepting a PR adding some kind of support for this? I opened the discussion here since sqlite-data is what i use, but I'm not quite sure how it would slot in nicely. Adding a new requirement to QueryDecoder in structured-queries feels kinda wrong since this is rather SQLite specific. GRDB has the
DatabaseValuetype which fits, I guess conforming that toQueryDecodableand casting the QueryDecoder ininit(decoder:)to then call a sqlite-specific func could work.Beta Was this translation helpful? Give feedback.
All reactions