[Request] Add a `check` utility for test purposes
Basically similar to doobie's approach. Take a Query as an input, validate against a server connection that the query as written matches the types.
It shouldn't require inserting any rows, only that the tables involved exist.
Full-fledged integration tests for certain queries are often hard to write. They might involve many foreign key relations, and thus a lot of distracting and fiddly test setup, or they might be highly-parameterized queries (in terms of the sql structure - imagine a "list from table, maybe sort on a user-selected property, sometimes filter some other property by a user input, etc").
We could add something to Session like
def check(query: Query[_, _]): F[Unit] = prepare(query).use(_ => Applicative[F].unit)
// ditto for Command
and then provide doc on how to make a Session available in various unit testing frameworks. But I don't really want to add modules like we did with doobie because it becomes a maintenance issue.
So prepare does the type validation, even prior to executing the query? That's not bad at all!
Yes, it does Parse which will catch syntax errors, and then Describe which will catch any type mismatches. See https://github.com/tpolecat/skunk/blob/master/modules/core/src/main/scala/net/protocol/Prepare.scala#L43-L44