<i>but I really hate ORM’s and this was just a giant nuisance to deal with</i><p>I like object relational mapping as a theory (ie. I have an object of type Author which has 1 or more books I can loop over), but I hate ActiveRecord implementations. Eventually, they just end up implementing almost all of SQL but in some arcane bullshit syntax or sequence of method calls that you have to spend a bunch of time learning.<p>I also seriously doubt that anyone has ever written a production system of any reasonable complexity and been able to use the exact same ORM code with absolutely any backend (if you have an example please correct me on this). This barely even works with something like PDO in PHP which is a bare bones abstraction across multiple SQL backends.<p>When it comes down to it, the benefits of ActiveRecord are all but dead on about the third day of development. The data mapper pattern adopted by SQLAlchemy (et. al.) takes all of the shitness of ActiveRecord and adds mind bending complexity to it.<p>SQL is easy to learn and very expressive. Why try and abstract it?<p>I spent years working with an ActiveRecord ORM I wrote myself in my feckless youth and thought that it was the answer to the world's problems. I didn't really understand why it was so terrible until I did a large project in Django and had to use someone <i>else's</i> ORM.<p>When I really analysed it, there were only three things that I really wanted out of an ORM:<p>1) Make the task of writing complex join statements a bit less tedious<p>2) Make the task of writing a sub-set of very basic where clauses slightly less tedious<p>3) Obviate the need for me to detect primary key changes when iterating over a joined result set to detect changes in an object (for example, looping over a list of Authors and their Books)<p>To that end, I wrote this:<p><a href="https://github.com/iaindooley/PluSQL" rel="nofollow">https://github.com/iaindooley/PluSQL</a><p>It's written in PHP because I like and use PHP but it's a very simple pattern that I would like to see elaborated upon/taken to other languages as I think it provides just the bare minimum amount of functionality to give some real productivity gains without creating a steep learning curve, performance trade-off or any barrier to just writing out SQL statements if that's the fastest way to solve the problem at hand.