Type-Checking SQL Queries With Crystal Macros

I just wrote a blog post about abusing Crystal macros and the type system to check the validity of SQL queries: Type-Checking SQL Queries With Crystal Macros

You can have a look at the full code here.

It’s all a hack and a proof of concept, but maybe interesting to see what you can do with the type system and macros.

I previously implemented dependency injection with macros.

Very cool