5 ms·
Thinking about this more. I think this project has some promising practical uses when combined with code generation from the typescript ast (which is what my pr
by ricksharp 6y ago
Thinking about this more. I think this project has some promising practical uses when combined with code generation from the typescript ast (which is what my project does).
Since the type system can parse the SQL strings, then it becomes possible to include those strings as a source for the ast. Then the code generator can use the typescript parser to parse all the types and the sql. From that it can generate all the required code to create the runtime queries.
I don’t like ORMs because they make it very difficult to write complex queries (and my own attempt did not solve that very well - I still had to manually type any complex queries). However, if this could essentially allow writing a complex query in raw sql and have it type-checked at code-time, it becomes easier to use. Then the code generator would convert that into a type-safe runtime library which solves 2 problems: 1. The poor editor performance of the type system inferring so many nested types. 2. Actually having a runtime that executes the queries.
The outstanding problem would be migrations...
Anyway, this is certainly a thought provoking project.
- thrashh 6y agoI find the ORM in SQLAlchemy pretty cool — I’ve really written complex queries as if I had witten it by hand but then finally mapped them into the ORM at the end with like a line of code. However it was a learning curve to figure out how to do it at first, but I didn’t have to drop down to raw SQL
- gfody 6y agomy thoughts as well. compile-time checked arbitrary sql would defeat the purpose of so many abominable ORMs. make it work with DDL instead of sample data and you've really got something nice!
- throwaway7422u 6y agoThis project does exactly that (TypeScript/PostgreSQL): https://github.com/MedFlyt/mfsqlchecker https://github.com/MedFlyt/mfsqlchecker
- ricksharp 6y agoThat looks pretty nice. I’ll have to check that out.