This reverts 7ffc332327
At the time, selectID was replaced with selectPrimaryKey(as:) because:
> Since Optional is a database value like others, selectID would be a request of optionals for records with an optional ID type:
>
> struct Player: Identifiable, MutablePersistableRecord {
> var id: Int64?
> }
>
> Player.selectID() // QueryInterface<Int64?>
>
> This is not good, because primary keys are not null. And those requests would fetch impractical types such as [Int64?], Set<Int64?>, Int64??.
This problem is reintroduced, but we now recommend against optional ids in https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/recordrecommendedpractices. And record with optional ids can use selectPrimaryKey(as:).
We were frequently turning those sequences into an Array in order to check their emptiness, and generally were not sure we'd iterate a sequence only once.
Also use `some Sequence` and `some Collection` whenever possible.
Since Optional is a database value like others, selectID would be a request of optionals for records with an optional ID type:
struct Player: Identifiable, MutablePersistableRecord {
var id: Int64?
}
Player.selectID() // QueryInterface<Int64?>
This is not good, because primary keys are not null. And those requests would fetch impractical types such as [Int64?], Set<Int64?>, Int64??.
Instead, we introduce selectPrimaryKey(as:), which allows the user to provide the desired type.
Player.selectPrimaryKey(as: Int64.self) // QueryInterface<Int64>
SQLSource used to be more or less able to deal with subqueries, as in SELECT ... FROM (SELECT ...).
But we had only one use case for it, the "trivial count query": SELECT COUNT(*) FROM (SELECT ...). And many opportunities for fatal errors, because such subqueries were not generally supported.
So we simplify SQLSource, and implement the trivial count query in another way.