Replies: 1 comment 2 replies
-
Hi @tevelee, would it be possible for you to flesh out these ideas a bit more and provide some concrete ramifications of embarking on something like this? What do we have to gain by making Right now we are only focused on SQL, and in particular SQLite, but we do have plans to make the library work equally well with MySQL and Postgres. |
Beta Was this translation helpful? Give feedback.
2 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.
-
First off, I want to say that this project is an exciting and noble effort! The structured query system you’re building is a fantastic addition to Swift, and I appreciate the thoughtfulness behind
@Table
,@Column
, and their ability to generate Hashable query representations, render them into SQL, and generate Draft structures.As I was exploring the design through the video series, I couldn’t help but notice that
@Table
and@Column
are effectively specialized versions of a more general concept: serialization. Specifically, these macros allow for:This closely mirrors how Codable works in Swift, where field names and encoding/decoding strategies can be customized. Given this similarity, I’d like to propose a generalization.
A more general
@Serializable
/@Field
macro could provide customization for model and property naming, as well as serialization strategies.@Table
could then extend this functionality by adding support for Draft structures and ensuring that fields are SQLRepresentable. For example, Date is not directly representable in SQL, so it requires a custom encoding/decoding strategy to convert it into a String or Int. Similarly, MySQL does not natively support boolean fields, so they require a coding strategy to convert them into TINYINTs, whereas JSON (via Codable) does support booleans natively.I’m not suggesting a wholesale replacement or reimplementation of Codable, but rather encouraging a broader perspective on serialization—beyond just queries. The ability to define serialization strategies and model relationships could have broader applications beyond SQL, making this approach more flexible and reusable.
It’s a half-baked idea, but I still wanted to share it. Let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions