Type-safe CTE associations, part 2

This commit is contained in:
Gwendal Roué committed 2020-12-01 20:04:35 +01:00
1 parent 67bc47c3b5
commit 06000abbfd
2 files changed
+7 -3

No files matched your search

@@ -88,7 +88,11 @@ extension CommonTableExpression {
extension _FetchRequest {
#warning("TODO: doc")
public func commonTableExpression<RowDecoder>(tableName: String) -> CommonTableExpression<RowDecoder> {
public func commonTableExpression<RowDecoder>(
tableName: String,
type: RowDecoder.Type = RowDecoder.self)
-> CommonTableExpression<RowDecoder>
{
CommonTableExpression(
tableName: tableName,
request: self)
@@ -12,8 +12,8 @@ class CommonTableExpressionTests: GRDBTestCase {
// Just add a WITH clause: query interface request
do {
enum CTE { }
let cte: CommonTableExpression<CTE> = T.all()
.commonTableExpression(tableName: "cte")
let cte = T.all()
.commonTableExpression(tableName: "cte", type: CTE.self)
let request = T.all()
.with(cte)
try assertEqualSQL(db, request, """