Skip to content

Commit 80b0af7

Browse files
authored
Add utilities for working with SQLAdditionalBinaryOperator and PostgreSQLBinaryStringOperator (#13)
As of Swift 6.2, the typechcker can handle there being `.expr()`, `.where()`, `.orWhere()`, `.having()`, and `.orHaving()` overloads for `SQLAdditionalBinaryOperator` and `PostgreSQLBinaryStringOperator`, as long as the overload set does not include overloads which accept `some SQLExpression` as the right-hand expression. Therefore, the safely usable overloads are now included. The package's minimum Swift version requirement has also been raised to 6.2.
1 parent c4fa356 commit 80b0af7

20 files changed

Lines changed: 458 additions & 55 deletions

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:6.1
1+
// swift-tools-version:6.2
22
import PackageDescription
33

44
let package = Package(

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
<p align="center">
2-
<img src="./Sources/SQLKitExtras/Documentation.docc/Resources/sql-kit-extras.svg" width="192" height="192">
3-
</p>
4-
<h1 align="center">SQLKitExtras</h1>
5-
61
<div align="center">
72

3+
<img src="./Sources/SQLKitExtras/Documentation.docc/Resources/sql-kit-extras.svg" width="192" height="192">
4+
<br>
5+
<h1>SQLKitExtras</h1>
6+
87
[![Vapor Chat](https://design.vapor.codes/images/discordchat.svg)](https://discord.gg/vapor)
98
[![MIT License](https://design.vapor.codes/images/mitlicense.svg)](./LICENSE)
109
[![Continuous Integration](https://img.shields.io/github/actions/workflow/status/vapor-community/sql-kit-extras/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=ccc)](https://github.com/vapor-community/sql-kit-extra/actions/workflows/test.yml)
1110
[![Code Coverage](https://img.shields.io/codecov/c/github/vapor-community/sql-kit-extras?style=plastic&logo=codecov&label=codecov)](https://codecov.io/github/vapor-community/sql-kit-extras)
12-
[![Swift 6.1+](https://design.vapor.codes/images/swift61up.svg)](https://swift.org)
11+
[![Swift 6.2+](https://design.vapor.codes/images/swift62up.svg)](https://swift.org)
1312
[![Platform Compatibility](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fvapor-community%2Fsql-kit-extras%2Fbadge%3Ftype%3Dplatforms&style=plastic&color=09f)](https://swiftpackageindex.com/vapor-community/sql-kit-extras)
1413

1514
</div>

Sources/FluentKitExtras/FlatGroupProperty.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extension Model {
5151
/// everything appears to work correctly at first, it will eventually cause enough confusion
5252
/// in Fluent to have unpredictable results.
5353
@propertyWrapper @dynamicMemberLookup
54-
public final class FlatGroupProperty<Model, Value>
54+
public final class FlatGroupProperty<Model, Value>: SendableMetatype
5555
where Model: FluentKit.Fields, Value: FluentKit.Fields
5656
{
5757
/// The underlying storage of the properties nested on `Value`. It is optional

Sources/FluentKitExtras/OptionalPointerProperty.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extension Model {
55
public typealias OptionalPointer<To, ToProp> = OptionalPointerProperty<Self, To, ToProp>
66
where
77
To: FluentKit.Model,
8-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
8+
ToProp: FluentKit.QueryableProperty & SendableMetatype,
99
ToProp.Model == To, ToProp.Value: Hashable
1010
}
1111

@@ -30,7 +30,7 @@ extension Model {
3030
public final class OptionalPointerProperty<From, To, ToProp>: @unchecked Sendable
3131
where
3232
From: FluentKit.Model, To: FluentKit.Model,
33-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
33+
ToProp: FluentKit.QueryableProperty & SendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
3434
{
3535
@OptionalFieldProperty<From, ToProp.Value>
3636
public var ref: ToProp.Value?
@@ -185,7 +185,7 @@ extension OptionalPointerProperty: EagerLoadable {
185185
private struct OptionalPointerEagerLoader<From, To, ToProp>: EagerLoader
186186
where
187187
From: FluentKit.Model, To: FluentKit.Model,
188-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
188+
ToProp: FluentKit.QueryableProperty & SendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
189189
{
190190
// Needed because the extension that normally adds this inside FluentKit is not public.
191191
func anyRun(models: [any AnyModel], on database: any Database) -> EventLoopFuture<Void> {
@@ -236,7 +236,7 @@ private struct ThroughOptionalPointerEagerLoader<From, Through, ThroughProp, Loa
236236
where
237237
From: FluentKit.Model,
238238
Loader: EagerLoader, Loader.Model == Through,
239-
ThroughProp: QueryableProperty & _SQLKitExtrasSendableMetatype, ThroughProp.Model == Through, ThroughProp.Value: Hashable
239+
ThroughProp: QueryableProperty & SendableMetatype, ThroughProp.Model == Through, ThroughProp.Value: Hashable
240240
{
241241
// Needed because the extension that normally adds this inside FluentKit is not public.
242242
func anyRun(models: [any AnyModel], on database: any Database) -> EventLoopFuture<Void> {

Sources/FluentKitExtras/OptionalReferenceProperty.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extension Model {
44
public typealias OptionalReference<To, FromProp> = OptionalReferenceProperty<Self, To, FromProp>
55
where
66
To: FluentKit.Model,
7-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, FromProp.Model == Self, FromProp.Value: Hashable
7+
FromProp: FluentKit.QueryableProperty & SendableMetatype, FromProp.Model == Self, FromProp.Value: Hashable
88
}
99

1010
// MARK: Type
@@ -21,7 +21,7 @@ extension Model {
2121
@propertyWrapper
2222
public final class OptionalReferenceProperty<From, To, FromProp>: @unchecked Sendable
2323
where From: FluentKit.Model, To: FluentKit.Model,
24-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
24+
FromProp: FluentKit.QueryableProperty & SendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
2525
{
2626
public let parentKey: RelationPointerKey<From, To, FromProp>
2727
let fromKeypath: KeyPath<From, FromProp>
@@ -228,7 +228,7 @@ extension OptionalReferenceProperty: EagerLoadable {
228228
private struct OptionalReferenceEagerLoader<From, To, FromProp>: EagerLoader
229229
where
230230
From: FluentKit.Model, To: FluentKit.Model,
231-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
231+
FromProp: FluentKit.QueryableProperty & SendableMetatype,
232232
FromProp.Model == From, FromProp.Value: Hashable
233233
{
234234
// Needed because the extension that normally adds this inside FluentKit is not public.
@@ -270,7 +270,7 @@ private struct OptionalReferenceEagerLoader<From, To, FromProp>: EagerLoader
270270
private struct ThroughReferenceEagerLoader<From, Through, FromProp, Loader>: EagerLoader
271271
where
272272
From: FluentKit.Model,
273-
Loader: EagerLoader, Loader.Model == Through, FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
273+
Loader: EagerLoader, Loader.Model == Through, FromProp: FluentKit.QueryableProperty & SendableMetatype,
274274
FromProp.Model == From, FromProp.Value: Hashable
275275
{
276276
// Needed because the extension that normally adds this inside FluentKit is not public.

Sources/FluentKitExtras/PointerProperty.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extension Model {
55
public typealias Pointer<To, ToProp> = PointerProperty<Self, To, ToProp>
66
where
77
To: FluentKit.Model,
8-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
8+
ToProp: FluentKit.QueryableProperty & SendableMetatype,
99
ToProp.Model == To, ToProp.Value: Hashable
1010
}
1111

@@ -29,7 +29,7 @@ extension Model {
2929
@propertyWrapper
3030
public final class PointerProperty<From, To, ToProp>: @unchecked Sendable
3131
where From: FluentKit.Model, To: FluentKit.Model,
32-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
32+
ToProp: FluentKit.QueryableProperty & SendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
3333
{
3434
@FieldProperty<From, ToProp.Value>
3535
public var ref: ToProp.Value
@@ -184,7 +184,7 @@ extension PointerProperty: EagerLoadable {
184184
private struct PointerEagerLoader<From, To, ToProp>: EagerLoader
185185
where
186186
From: FluentKit.Model, To: FluentKit.Model,
187-
ToProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
187+
ToProp: FluentKit.QueryableProperty & SendableMetatype, ToProp.Model == To, ToProp.Value: Hashable
188188
{
189189
// Needed because the extension that normally adds this inside FluentKit is not public.
190190
func anyRun(models: [any AnyModel], on database: any Database) -> EventLoopFuture<Void> {
@@ -222,7 +222,7 @@ private struct ThroughPointerEagerLoader<From, Through, ThroughProp, Loader>: Ea
222222
where
223223
From: FluentKit.Model,
224224
Loader: EagerLoader, Loader.Model == Through,
225-
ThroughProp: QueryableProperty & _SQLKitExtrasSendableMetatype, ThroughProp.Model == Through, ThroughProp.Value: Hashable
225+
ThroughProp: QueryableProperty & SendableMetatype, ThroughProp.Model == Through, ThroughProp.Value: Hashable
226226
{
227227
// Needed because the extension that normally adds this inside FluentKit is not public.
228228
func anyRun(models: [any AnyModel], on database: any Database) -> EventLoopFuture<Void> {

Sources/FluentKitExtras/ReferencesProperty.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extension Model {
44
public typealias References<To, FromProp> = ReferencesProperty<Self, To, FromProp>
55
where
66
To: FluentKit.Model,
7-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
7+
FromProp: FluentKit.QueryableProperty & SendableMetatype,
88
FromProp.Model == Self, FromProp.Value: Hashable
99
}
1010

@@ -23,7 +23,7 @@ extension Model {
2323
public final class ReferencesProperty<From, To, FromProp>: @unchecked Sendable
2424
where
2525
From: FluentKit.Model, To: FluentKit.Model,
26-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
26+
FromProp: FluentKit.QueryableProperty & SendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
2727
{
2828
public let parentKey: RelationPointerKey<From, To, FromProp>
2929
let fromKeypath: KeyPath<From, FromProp>
@@ -243,7 +243,7 @@ extension ReferencesProperty: EagerLoadable {
243243
private struct ReferencesEagerLoader<From, To, FromProp>: EagerLoader
244244
where
245245
From: FluentKit.Model, To: FluentKit.Model,
246-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
246+
FromProp: FluentKit.QueryableProperty & SendableMetatype, FromProp.Model == From, FromProp.Value: Hashable
247247
{
248248
// Needed because the extension that normally adds this inside FluentKit is not public.
249249
func anyRun(models: [any AnyModel], on database: any Database) -> EventLoopFuture<Void> {
@@ -282,7 +282,7 @@ private struct ReferencesEagerLoader<From, To, FromProp>: EagerLoader
282282
private struct ThroughReferencesEagerLoader<From, Through, FromProp, Loader>: EagerLoader
283283
where
284284
From: FluentKit.Model,
285-
Loader: EagerLoader, Loader.Model == Through, FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
285+
Loader: EagerLoader, Loader.Model == Through, FromProp: FluentKit.QueryableProperty & SendableMetatype,
286286
FromProp.Model == From, FromProp.Value: Hashable
287287
{
288288
// Needed because the extension that normally adds this inside FluentKit is not public.

Sources/FluentKitExtras/RelationPointerKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ public import FluentKit
33
public enum RelationPointerKey<From, To, FromProp>: Sendable
44
where
55
From: FluentKit.Model, To: FluentKit.Model,
6-
FromProp: FluentKit.QueryableProperty & _SQLKitExtrasSendableMetatype,
6+
FromProp: FluentKit.QueryableProperty & SendableMetatype,
77
FromProp.Model == From, FromProp.Value: Hashable
88
{
99
case required(KeyPath<To, To.Pointer<From, FromProp>>)

Sources/FluentKitExtras/RequiredTimestampProperty.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension Model {
1414
/// A Fluent property wrapper which provides the same functionality as the built-in `TimestampProperty` wrapper,
1515
/// except that its value is not optional.
1616
@propertyWrapper
17-
public final class RequiredTimestampProperty<Model, Format>
17+
public final class RequiredTimestampProperty<Model, Format>: SendableMetatype
1818
where
1919
Model: FluentKit.Model,
2020
Format: TimestampFormat
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import FluentKit
22

3-
#if compiler(>=6.2)
3+
@available(*, deprecated, renamed: "SendableMetatype", message: "Use SendableMetatype instead.")
44
public typealias _SQLKitExtrasSendableMetatype = SendableMetatype
5-
#else
6-
public typealias _SQLKitExtrasSendableMetatype = Any
7-
#endif
85

9-
extension FluentKit.BooleanProperty: _SQLKitExtrasSendableMetatype {}
10-
extension FluentKit.OptionalBooleanProperty: _SQLKitExtrasSendableMetatype {}
11-
12-
extension FlatGroupProperty: _SQLKitExtrasSendableMetatype {}
13-
extension OptionalPointerProperty: _SQLKitExtrasSendableMetatype {}
14-
extension OptionalReferenceProperty: _SQLKitExtrasSendableMetatype {}
15-
extension PointerProperty: _SQLKitExtrasSendableMetatype {}
16-
extension ReferencesProperty: _SQLKitExtrasSendableMetatype {}
17-
extension RequiredTimestampProperty: _SQLKitExtrasSendableMetatype {}
6+
extension BooleanProperty: @retroactive SendableMetatype {}
7+
extension OptionalBooleanProperty: @retroactive SendableMetatype {}

0 commit comments

Comments
 (0)