It feels likely that once I realize the full implications of this, it will no longer seem desirable. But with my limited knowledge of type systems, I want this:
- Define a typed RMDB structure using objects.
- Create a typed SQL query using the above structure without any strings. It would make sure that I can not, e.g.:
- Select fields that aren't among the joined tables
- Join on an under-specified condition (e.g. not whole foreign key in join)
- Compare incompatible data types
- Have this executed efficiently, perhaps as multiple queries.
- Finally, have the result object types be derived from the above.
- Relations as a tree/graph of objects (not a table)
- Field types derived from RMDB structure
- Nullability based on join conditions
- Not contain the fields which weren't retrieved
It seems like a stretch for the (few) type systems that I know. Using a full macro system would decrease clarity and IDE support. So I'm hoping there's some way to do these 'derived' types.
(So to be clear, I'm talking about features in a general programming language, not a DSL)