> But this is the generic facility for database access. This is just an additional special case it has to handle.
Presumably it would be using a lower layer - or more likely an existing library - for doing the actual query though?
> I could filter on the wrong column,
Not if you've got a typed representation of which column's which
> with the wrong operator,
Not if equality is the only operator available. This is one of my biggest reasons for using wrapper types around IDs - you shouldn't treat IDs as integers, because the idea of adding or multiplying or <=ing an ID makes no sense.
> with the wrong value,
How? You have to use the passed ID for something, and it can't do anything else.
> on the wrong table.
So make the table part of the type. A list ID is a different thing from a user ID, they shouldn't be compatible.
> I could decode the name column using the wrong encoding.
Encoding should absolutely be handled with types.
> I could return multiple rows per option.
Hmm, maybe. But I can't see how you'd do that by accident.
> At the end of the day, even in a statically typed language where much of the functionality would be verified by the compiler, I'd still like to have a test on this.
I started out thinking the same thing (I moved from Java/Python to Scala). I've gradually reduced the amount of tests I write over four years as I've found them to not add value. I was as surprised as anyone, and even privately entertained the thought that maybe I was some kind of super-programmer who was smarter than all those people who needed tests, but that month or two of trying to do stuff in Django made it very clear that it wasn't me, it was the language.
> Hmm... the fact that it deals with the boundary of the system and the fact that it deals only with converting data from one format to another might render it a poor sample (i.e. there's not really much interesting logic). I can come up with another if you are interested.
Yeah, happy to if you're interested. It's a useful exercise in thinking it through for myself as much as anything.