mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Allow grouping by FastPrimaryKeyExpression
This commit is contained in:
1 parent
2201026ce8
commit
a328faa834
1 file changed
+14
-5
@@ -500,6 +500,20 @@ struct SQLQueryGenerator: Refinable {
|
||||
return .none
|
||||
}
|
||||
|
||||
// Grouping something which is not a table: assume non unique grouping.
|
||||
guard case let .table(tableName: tableName, alias: alias) = relation.source else {
|
||||
return .nonUnique
|
||||
}
|
||||
|
||||
// FastPrimaryKeyExpression?
|
||||
for expression in groupExpressions {
|
||||
if
|
||||
let column = expression as? QualifiedFastPrimaryKeyExpression,
|
||||
column.alias == alias {
|
||||
return .unique
|
||||
}
|
||||
}
|
||||
|
||||
// Grouping by something which is not a column: assume non
|
||||
// unique grouping.
|
||||
// SELECT * FROM player GROUP BY (score + bonus)
|
||||
@@ -508,11 +522,6 @@ struct SQLQueryGenerator: Refinable {
|
||||
return .nonUnique
|
||||
}
|
||||
|
||||
// Grouping something which is not a table: assume non unique grouping.
|
||||
guard case let .table(tableName: tableName, alias: alias) = relation.source else {
|
||||
return .nonUnique
|
||||
}
|
||||
|
||||
// Grouping by some column(s) which do not come from the main table:
|
||||
// assume non unique grouping.
|
||||
// SELECT * FROM player JOIN team ... GROUP BY team.id
|
||||
|
||||
Reference in new issue
Block a user