Comments (6)
Thank you Stephen. For the record, one can use Tagged with GRDB 5.9.0 with the following extensions:
import GRDB
import Tagged
// Make it possible to use Tagged types as database values
// just line Int, String, Date, etc.
extension Tagged: SQLExpressible where RawValue: SQLExpressible { }
extension Tagged: StatementBinding where RawValue: StatementBinding { }
extension Tagged: DatabaseValueConvertible where RawValue: DatabaseValueConvertible { }
from swift-tagged.
Oh, and here is how MyEntity
is defined:
public struct MyEntity: Codable {
public typealias Id = Tagged<MyEntity, Int>
public let id: Id
}
In addition, writing to a SQLite database works fine. It's only in reading the value out that I get this error.
from swift-tagged.
Here is a toy example that reproduces the crash. Just run swift test
from the root of the project.
https://github.com/danramteke/TaggedSqliteSwiftStudy
from swift-tagged.
@danramteke Not sure if you still need this, but maybe someone else could find it useful. I was able to get your test passing by doing this.
extension Tagged: Value, Expressible where RawValue: Value {
public static var declaredDatatype: String {
return RawValue.declaredDatatype
}
public static func fromDatatypeValue(_ datatypeValue: RawValue.Datatype) -> Self {
return Self(rawValue: RawValue.fromDatatypeValue(datatypeValue) as! RawValue)
}
public var datatypeValue: RawValue.Datatype {
return rawValue.datatypeValue
}
}
from swift-tagged.
I ended up switching to GRDB. It's very well thought out and supports Combine as well. https://github.com/groue/GRDB.swift
from swift-tagged.
Hi @danramteke :) GRDB is very good. SQLite.swift has some nice maintainers, but I don't think they have nearly the time to dedicate compared to the steward of GRDB these days, and I walked away from the project many years ago, when I was no longer working with SQLite in any of my projects at a capacity that necessitated a library. Going to close this out since you found an alternate solution.
from swift-tagged.
Related Issues (16)
- Are consumers able to override default Codable conditional conformances? HOT 2
- Add Info.plist
- Unused dependency in Package.swift? HOT 6
- Deploy to CocoaPods HOT 2
- Custom date decoding issue HOT 5
- Decodable issue when using Tagged type as key in Dictionary HOT 1
- Does `ExpressiblebyArrayLiteral` code still need to be commented out? HOT 2
- New Release? HOT 2
- [Remove me]
- Unexpected behavior HOT 5
- CodingKeyRepresentable Conformance HOT 1
- Support `SignedInteger` where `RawValue: SignedInteger`
- Issue building with Carthage when targeting older iOS SDK
- Conform to EntityIdentifierConvertible HOT 1
- Tagged String - "Ambiguous use of "init(_:)'" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-tagged.