Giter Club home page Giter Club logo

Comments (6)

groue avatar groue commented on September 25, 2024 3

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.

danramteke avatar danramteke commented on September 25, 2024

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.

danramteke avatar danramteke commented on September 25, 2024

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.

iampatbrown avatar iampatbrown commented on September 25, 2024

@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.

danramteke avatar danramteke commented on September 25, 2024

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.

stephencelis avatar stephencelis commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.