Skip to content

Commit 887545d

Browse files
committed
Add swift-tagged trait
1 parent 20f1a56 commit 887545d

File tree

4 files changed

+192
-2
lines changed

4 files changed

+192
-2
lines changed

Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.0
1+
// swift-tools-version: 6.1
22

33
import CompilerPluginSupport
44
import PackageDescription
@@ -29,11 +29,19 @@ let package = Package(
2929
targets: ["StructuredQueriesSQLite"]
3030
),
3131
],
32+
traits: [
33+
.trait(
34+
name: "TaggedStructuredQueries",
35+
description: "Introduce StructuredQueries conformances to the swift-tagged package.",
36+
enabledTraits: []
37+
),
38+
],
3239
dependencies: [
3340
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
3441
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.8.1"),
3542
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.6.0"),
3643
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.1"),
44+
.package(url: "https://github.com/pointfreeco/swift-tagged", from: "0.10.0"),
3745
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.2"),
3846
.package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"601.0.0"),
3947
],
@@ -43,6 +51,11 @@ let package = Package(
4351
dependencies: [
4452
"StructuredQueriesSupport",
4553
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
54+
.product(
55+
name: "Tagged",
56+
package: "swift-tagged",
57+
condition: .when(traits: ["TaggedStructuredQueries"])
58+
),
4659
]
4760
),
4861
.target(

[email protected]

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// swift-tools-version: 6.0
2+
3+
import CompilerPluginSupport
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "swift-structured-queries",
8+
platforms: [
9+
.iOS(.v13),
10+
.macOS(.v10_15),
11+
.tvOS(.v13),
12+
.watchOS(.v6),
13+
],
14+
products: [
15+
.library(
16+
name: "StructuredQueries",
17+
targets: ["StructuredQueries"]
18+
),
19+
.library(
20+
name: "StructuredQueriesCore",
21+
targets: ["StructuredQueriesCore"]
22+
),
23+
.library(
24+
name: "StructuredQueriesTestSupport",
25+
targets: ["StructuredQueriesTestSupport"]
26+
),
27+
.library(
28+
name: "_StructuredQueriesSQLite",
29+
targets: ["StructuredQueriesSQLite"]
30+
),
31+
],
32+
dependencies: [
33+
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
34+
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.8.1"),
35+
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.6.0"),
36+
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.1"),
37+
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.2"),
38+
.package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"601.0.0"),
39+
],
40+
targets: [
41+
.target(
42+
name: "StructuredQueriesCore",
43+
dependencies: [
44+
"StructuredQueriesSupport",
45+
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
46+
]
47+
),
48+
.target(
49+
name: "StructuredQueries",
50+
dependencies: [
51+
"StructuredQueriesCore",
52+
"StructuredQueriesMacros",
53+
]
54+
),
55+
.macro(
56+
name: "StructuredQueriesMacros",
57+
dependencies: [
58+
"StructuredQueriesSupport",
59+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
60+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
61+
]
62+
),
63+
.target(
64+
name: "StructuredQueriesSQLite",
65+
dependencies: [
66+
"StructuredQueries"
67+
]
68+
),
69+
.target(
70+
name: "StructuredQueriesTestSupport",
71+
dependencies: [
72+
"StructuredQueriesCore",
73+
.product(name: "CustomDump", package: "swift-custom-dump"),
74+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
75+
]
76+
),
77+
.testTarget(
78+
name: "StructuredQueriesMacrosTests",
79+
dependencies: [
80+
"StructuredQueries",
81+
"StructuredQueriesMacros",
82+
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
83+
.product(name: "MacroTesting", package: "swift-macro-testing"),
84+
]
85+
),
86+
.testTarget(
87+
name: "StructuredQueriesTests",
88+
dependencies: [
89+
"StructuredQueries",
90+
"StructuredQueriesSQLite",
91+
"StructuredQueriesTestSupport",
92+
.product(name: "CustomDump", package: "swift-custom-dump"),
93+
.product(name: "Dependencies", package: "swift-dependencies"),
94+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
95+
]
96+
),
97+
98+
.target(name: "StructuredQueriesSupport"),
99+
],
100+
swiftLanguageModes: [.v6]
101+
)
102+
103+
let swiftSettings: [SwiftSetting] = [
104+
.enableUpcomingFeature("MemberImportVisibility")
105+
// .unsafeFlags([
106+
// "-Xfrontend",
107+
// "-warn-long-function-bodies=50",
108+
// "-Xfrontend",
109+
// "-warn-long-expression-type-checking=50",
110+
// ])
111+
]
112+
113+
for index in package.targets.indices {
114+
package.targets[index].swiftSettings = swiftSettings
115+
}
116+
117+
#if !os(Darwin)
118+
package.targets.append(
119+
.systemLibrary(
120+
name: "StructuredQueriesSQLite3",
121+
providers: [.apt(["libsqlite3-dev"])]
122+
)
123+
)
124+
125+
for index in package.targets.indices {
126+
if package.targets[index].name == "StructuredQueriesSQLite" {
127+
package.targets[index].dependencies.append("StructuredQueriesSQLite3")
128+
}
129+
}
130+
#endif
131+
132+
#if !os(Windows)
133+
// Add the documentation compiler plugin if possible
134+
package.dependencies.append(
135+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
136+
)
137+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#if TaggedStructuredQueries
2+
import Tagged
3+
4+
extension Tagged: _OptionalPromotable where RawValue: _OptionalPromotable {}
5+
6+
extension Tagged: QueryBindable where RawValue: QueryBindable {}
7+
8+
extension Tagged: QueryDecodable where RawValue: QueryDecodable {}
9+
10+
extension Tagged: QueryExpression where RawValue: QueryExpression {
11+
public var queryFragment: QueryFragment {
12+
rawValue.queryFragment
13+
}
14+
}
15+
16+
extension Tagged: QueryRepresentable where RawValue: QueryRepresentable {
17+
public init(queryOutput: RawValue.QueryOutput) {
18+
self.init(RawValue(queryOutput: queryOutput))
19+
}
20+
21+
public var queryOutput: RawValue.QueryOutput {
22+
rawValue.queryOutput
23+
}
24+
}
25+
26+
extension Tagged: SQLiteType where RawValue: SQLiteType {
27+
public static var typeAffinity: SQLiteTypeAffinity {
28+
RawValue.typeAffinity
29+
}
30+
}
31+
#endif

0 commit comments

Comments
 (0)