From 7ff21981f0c443587f8ce06fef6549ff7cbf5395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 6 Mar 2019 09:08:59 +0100 Subject: [PATCH] Restore tests by disabling a sanity check --- .../SQLSelectable+QueryInterface.swift | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift b/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift index 411b88829..08fbe4c48 100644 --- a/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift @@ -78,10 +78,27 @@ extension QualifiedAllColumns : SQLSelectable { } func countedSQL(_ context: inout SQLGenerationContext) -> String { - if context.qualifier(for: alias) != nil { - // SELECT COUNT(t.*) is invalid SQL - fatalError("Not implemented, or invalid query") - } + // TODO: restore the check below. + // + // It is currently disabled because of AssociationAggregateTests.testHasManyIsEmpty: + // + // let request = Team.having(Team.players.isEmpty) + // try XCTAssertEqual(request.fetchCount(db), 1) + // + // This should build the trivial count query `SELECT COUNT(*) FROM (SELECT ...)` + // + // Unfortunately, we don't support anonymous table aliases that would be + // required here. Because we don't support anonymous tables aliases, + // everything happens as if we wanted to generate + // `SELECT COUNT(team.*) FROM (SELECT ...)`, which is invalid SQL. + // + // So let's always return `*`, and fix this later. + +// if context.qualifier(for: alias) != nil { +// // SELECT COUNT(t.*) is invalid SQL +// fatalError("Not implemented, or invalid query") +// } + return "*" }