3 ms·
I really wish there were one right answer, but it doesn’t seem like there is one. The last time I tried to write code with just raw SQL, the query patterns got
by hinkley 7y ago
I really wish there were one right answer, but it doesn’t seem like there is one.
The last time I tried to write code with just raw SQL, the query patterns got tedious really quickly, and I found myself using the most bizarre patterns to normalize query fragments and avoid typos in rarely used queries. It all made sense to me as I did it but others thought I was nuts. They were probably not wrong.
But every time I used an ORM or worked with people who did, things got sloppy, quickly.
- colonwqbang 7y agoIt's a pretty radical alternative but I've been playing a lot with the postgresql-typed library. It actually connects to the database during compile time, validates the queries and calculates appropriate type constraints for your application code. Simple typos are caught of course, but also more subtle problems. If for instance you drop a NOT NULL constraint on a column in your database, your application will not compile until you add in the appropriate NULL handling. Like I said it is a bit radical, but to me it clearly feels like the future and I miss it whenver I work with a traditional DB mapping.