Skip to content

Commit 21d6cea

Browse files
committed
wip
1 parent 74ec4d1 commit 21d6cea

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Sources/_StructuredQueriesSQLite/DatabaseFunction.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ private final class AggregateDatabaseFunctionIterator<
126126
>: AggregateDatabaseFunctionIteratorProtocol {
127127
let body: Body
128128
let stream = Stream<Body.Row>()
129-
let queue = DispatchQueue.global(qos: .userInitiated)
129+
let queue = DispatchQueue(
130+
label: "co.pointfree.StructuredQueriesSQLite.AggregateDatabaseFunction"
131+
)
130132
var _result: QueryBinding?
131133
init(_ body: Body) {
132134
self.body = body

Tests/StructuredQueriesTests/DatabaseFunctionTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,5 +554,29 @@ extension SnapshotTests {
554554
"""
555555
}
556556
}
557+
558+
@DatabaseFunction
559+
func tagged(_ tags: some Sequence<Tag>) -> String {
560+
tags.map { "#\($0.title)" }.joined(separator: " ")
561+
}
562+
563+
@Test func selectionTableAggregate() {
564+
$tagged.install(database.handle)
565+
566+
assertQuery(
567+
Tag.select { $tagged($0) }
568+
) {
569+
"""
570+
SELECT "tagged"("tags"."id", "tags"."title")
571+
FROM "tags"
572+
"""
573+
} results: {
574+
"""
575+
┌─────────────────────────────────┐
576+
"#car #kids #someday #optional"
577+
└─────────────────────────────────┘
578+
"""
579+
}
580+
}
557581
}
558582
}

0 commit comments

Comments
 (0)