Skip to content

Commit 92d1bc8

Browse files
authored
Restore Swift 6.1 support (#347)
* Restore Swift 6.1 support A few things were broken. * wip
1 parent b1b4fbf commit 92d1bc8

15 files changed

Lines changed: 171 additions & 158 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ jobs:
3737
name: Linux
3838
strategy:
3939
matrix:
40-
swift:
41-
- "6.3"
40+
swift: ["6.1", "6.3"]
4241
runs-on: ubuntu-latest
4342
container: swift:${{ matrix.swift }}
4443
steps:
4544
- uses: actions/checkout@v5
4645
- name: Install SQLite
4746
run: apt update && apt -y install libsqlite3-dev
4847
- name: Build
49-
run: swift build
48+
run: swift build --build-tests

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ let package = Package(
7777
dependencies: [
7878
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.8.0"),
7979
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
80-
.package(
81-
url: "https://github.com/pointfreeco/swift-dependencies",
82-
from: "1.14.0",
83-
traits: ["Foundation"]
84-
),
80+
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.14.0"),
8581
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.6.3"),
8682
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.4"),
8783
.package(url: "https://github.com/pointfreeco/swift-tagged", from: "0.10.0"),

Sources/StructuredQueries/Macros.swift

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public import StructuredQueriesCore
4242
named(allCasePaths),
4343
named(_$Element)
4444
)
45+
@attached(memberAttribute)
46+
public macro Table(
47+
_ name: String = "",
48+
schema schemaName: String = ""
49+
) =
50+
#externalMacro(
51+
module: "StructuredQueriesMacros",
52+
type: "TableMacro"
53+
)
4554
#else
4655
@attached(
4756
extension,
@@ -67,16 +76,16 @@ public import StructuredQueriesCore
6776
named(tableName),
6877
named(CodingKeys)
6978
)
79+
@attached(memberAttribute)
80+
public macro Table(
81+
_ name: String = "",
82+
schema schemaName: String = ""
83+
) =
84+
#externalMacro(
85+
module: "StructuredQueriesMacros",
86+
type: "TableMacro"
87+
)
7088
#endif
71-
@attached(memberAttribute)
72-
public macro Table(
73-
_ name: String = "",
74-
schema schemaName: String = ""
75-
) =
76-
#externalMacro(
77-
module: "StructuredQueriesMacros",
78-
type: "TableMacro"
79-
)
8089

8190
/// Defines a "selection" of columns that can be decoded from a query.
8291
///
@@ -144,6 +153,14 @@ public macro Table(
144153
named(allCasePaths),
145154
named(_$Element)
146155
)
156+
@attached(memberAttribute)
157+
public macro Selection(
158+
_ name: String = ""
159+
) =
160+
#externalMacro(
161+
module: "StructuredQueriesMacros",
162+
type: "TableMacro"
163+
)
147164
#else
148165
@attached(
149166
extension,
@@ -171,15 +188,15 @@ public macro Table(
171188
named(tableName),
172189
named(CodingKeys)
173190
)
191+
@attached(memberAttribute)
192+
public macro Selection(
193+
_ name: String = ""
194+
) =
195+
#externalMacro(
196+
module: "StructuredQueriesMacros",
197+
type: "TableMacro"
198+
)
174199
#endif
175-
@attached(memberAttribute)
176-
public macro Selection(
177-
_ name: String = ""
178-
) =
179-
#externalMacro(
180-
module: "StructuredQueriesMacros",
181-
type: "TableMacro"
182-
)
183200

184201
/// Customizes a column generated by the ``/StructuredQueriesCore/Table`` protocol.
185202
///

Sources/StructuredQueriesCore/Operators.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,6 @@ extension QueryExpression where QueryValue == Bool {
395395
}
396396
}
397397

398-
// NB: This overload is required due to an overload resolution bug of 'Updates[dynamicMember:]'.
399-
@_documentation(visibility: private)
400-
public prefix func ! (
401-
expression: any QueryExpression<Bool>
402-
) -> some QueryExpression<Bool> {
403-
func open(_ expression: some QueryExpression<Bool>) -> SQLQueryExpression<Bool> {
404-
SQLQueryExpression(expression.not())
405-
}
406-
return open(expression)
407-
}
408-
409398
extension SQLQueryExpression<Bool> {
410399
public mutating func toggle() {
411400
self = Self(not())

Sources/StructuredQueriesCore/ScalarFunctions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ extension QueryExpression where QueryValue: _OptionalPromotable {
7575
/// `NULL` when both expressions are equal.
7676
public func nullif<Other: QueryExpression>(
7777
_ other: Other
78-
) -> some QueryExpression<QueryValue._Optionalized>
78+
) -> SQLQueryExpression<QueryValue._Optionalized>
7979
where
8080
Other.QueryValue: _OptionalPromotable,
8181
Other.QueryValue._Optionalized == QueryValue._Optionalized
8282
{
83-
QueryFunction("nullif", self, other)
83+
SQLQueryExpression(QueryFunction("nullif", self, other))
8484
}
8585
}
8686

Tests/StructuredQueriesMacrosTests/TableMacroTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,7 +2840,7 @@ extension SnapshotTests {
28402840
}
28412841
}
28422842

2843-
@Test func `@Selection with empty struct`() {
2843+
@Test("@Selection with empty struct") func selectionWithEmptyStruct() {
28442844
assertMacro {
28452845
"""
28462846
@Selection
@@ -4063,7 +4063,7 @@ extension SnapshotTests {
40634063
}
40644064
}
40654065

4066-
@Test func `selection enum requires CasePaths trait`() {
4066+
@Test("selection enum requires CasePaths trait") func selectionEnumRequiresCasePathsTrait() {
40674067
assertMacro {
40684068
"""
40694069
@Selection enum Post {

Tests/StructuredQueriesTests/DatabaseFunctionTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import Dependencies
22
import Foundation
33
import InlineSnapshotTesting
4-
import SQLite3
54
import StructuredQueries
65
import StructuredQueriesSQLite
76
import StructuredQueriesTestSupport
87
import Testing
98
import _StructuredQueriesSQLite
109

10+
#if canImport(Darwin)
11+
import SQLite3
12+
#else
13+
import _StructuredQueriesSQLite3
14+
#endif
15+
1116
extension SnapshotTests {
1217
@Suite struct DatabaseFunctionTests {
1318
@Dependency(\.defaultDatabase) var database

Tests/StructuredQueriesTests/DecodingTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ extension SnapshotTests {
243243
)
244244
}
245245

246-
@Test func `NULL value in optional column does not decode as default`() throws {
246+
@Test("NULL value in optional column does not decode as default")
247+
func nullValueInOptionalColumnDoesNotDecodeAsDefault() throws {
247248
try withDependencies {
248249
$0.defaultDatabase = db
249250
} operation: {

Tests/StructuredQueriesTests/EnumTableTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@
644644
}
645645
}
646646

647-
@Test func `enum case with defaults isn't always decoded successfully`() {
647+
@Test("enum case with defaults isn't always decoded successfully")
648+
func enumCaseWithDefaultsIsntAlwaysDecodedSuccessfully() {
648649
assertQuery(
649650
Attachment.upsert {
650651
Attachment

Tests/StructuredQueriesTests/InsertTests.swift

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -715,27 +715,24 @@ extension SnapshotTests {
715715
}
716716
}
717717

718-
// NB: This currently crashes in Xcode 26.
719-
#if swift(<6.2)
720-
@Test func onConflict_invalidUpdateFilters() {
721-
withKnownIssue {
722-
assertQuery(
723-
Reminder.insert {
724-
Reminder.Draft(remindersListID: 1)
725-
} where: {
726-
$0.isFlagged
727-
}
728-
) {
729-
"""
730-
INSERT INTO "reminders"
731-
("id", "assignedUserID", "dueDate", "isCompleted", "isFlagged", "notes", "priority", "remindersListID", "title", "updatedAt")
732-
VALUES
733-
(NULL, NULL, NULL, 0, 0, '', NULL, 1, '', '2040-02-14 23:31:30.000')
734-
"""
718+
@Test func onConflict_invalidUpdateFilters() {
719+
withKnownIssue {
720+
assertQuery(
721+
Reminder.insert {
722+
Reminder.Draft(remindersListID: 1)
723+
} where: {
724+
$0.isFlagged
735725
}
726+
) {
727+
"""
728+
INSERT INTO "reminders"
729+
("id", "assignedUserID", "dueDate", "isCompleted", "isFlagged", "notes", "priority", "remindersListID", "title", "updatedAt")
730+
VALUES
731+
(NULL, NULL, NULL, 0, 0, '', NULL, 1, '', '2040-02-14 23:31:30.000')
732+
"""
736733
}
737734
}
738-
#endif
735+
}
739736

740737
@Test func onConflict_conditionalWhere() {
741738
let condition = false

0 commit comments

Comments
 (0)