<story><title>ORMs Are Backwards</title><url>https://abe-winter.github.io/2019/09/03/orms-backwards.html</url></story><parent_chain><item><author>nnq</author><text>...you&amp;#x27;re the &lt;i&gt;ONLY&lt;/i&gt; person I saw with a good opinion of Django&amp;#x27;s ORM. I&amp;#x27;m willing to accept you could be right in preferring it, but:&lt;p&gt;&lt;i&gt;Could you share some resources of using it properly for advanced use cases? Good cookbooks etc.&lt;/i&gt;&lt;p&gt;For, it&amp;#x27;s always been a huge footgun, coupled with Python&amp;#x27;s dynamic nature, it&amp;#x27;s and endless source of bug after bug... Mistype a property on a model instance - no problem, no error, it will just not get saved to the db and data will be lost. Use progres native json and array fields - good luck running your tests on sqlite, the ORM that was helpful up to here just gives up and tells you &amp;quot;f u buddy, you&amp;#x27;re on your own&amp;quot;. Need to write complex hand-coded-sql queries that return complicated data, but you&amp;#x27;s still want to be able to serialize them into a graph of objects that can then be modified by regular ORM code - good luck with that, nobody cared about this scenario.&lt;p&gt;&lt;i&gt;They&amp;#x27;ve somehow managed to make it too simple and too complex at the same time! Oh, and don&amp;#x27;t expect to just click a few jump to definitions an make sense of the ORM&amp;#x27;s inner code easily, god forbid :|...&lt;/i&gt;&lt;p&gt;While I like the &lt;i&gt;idea of ORMs&lt;/i&gt;, I found them all &lt;i&gt;totally &amp;quot;wrong headed&amp;quot;&lt;/i&gt; And SQLAlchemy - that&amp;#x27;s just not worth the effort of learning to use it properly despite its good ideas, if you&amp;#x27;re only going to end up using 10% of its functionality and in an idiosyncratic way that was not intended.</text></item><item><author>bayesian_horse</author><text>I have a lot of experience with the Django ORM, but no other.&lt;p&gt;So I disagree with most points.&lt;p&gt;The Django ORM does map pretty neatly to SQL (in my opinion), and especially Postgres. The migration tool is anything but &amp;quot;half-baked&amp;quot;. And I have observed that beginners have an easier time creating Django models than dealing with straight SQL.&lt;p&gt;On top of that, the Django ORM mitigates most SQL injection attacks out of the box, without even requiring the developer to know about SQL injections in the first place.&lt;p&gt;And the ORM enables elegant code reuse by constructing query objects that can be used in Template logic, Form validation, generic CRUD, REST endpoints and more.&lt;p&gt;I agree that most ORMs don&amp;#x27;t help you with multiple programming languages. Though both the Django ORM and SQLAlchemy allow to customize a lot of the naming conventions and can be adapted to any legacy schema.&lt;p&gt;But then again: Is it even a good idea to access the same database from two codebases at all?&lt;p&gt;Some of the concerns about &amp;quot;ORMs kill the SQL-star&amp;quot; can be boiled down to a lack of a general understanding of relational databases in developers who learn to use an ORM before diving deeper into the philosophy of relational databases.</text></item></parent_chain><comment><author>Fradow</author><text>This thread is littered with people singing praise of Django&amp;#x27;s ORM. He is not the only one. I&amp;#x27;m a huge proponent of it as well.&lt;p&gt;&amp;gt; Could you share some resources of using it properly for advanced use cases? Good cookbooks etc.&lt;p&gt;The official documentation covers advanced use cases. Stackoverflow will help you shape up more complicated queries.&lt;p&gt;&amp;gt; Mistype a property on a model instance - no problem, no error, it will just not get saved to the db and data will be lost.&lt;p&gt;That&amp;#x27;s a drawback of most dynamic languages, not a flaw of Django&amp;#x27;s ORM.&lt;p&gt;&amp;gt; Need to write complex hand-coded-sql queries that return complicated data, but you&amp;#x27;s still want to be able to serialize them into a graph of objects that can then be modified by regular ORM code - good luck with that, nobody cared about this scenario.&lt;p&gt;Maybe that&amp;#x27;s the threshold Django ORM devs thought sensible to stop supporting? At some point, mixing hand-coded-SQL and ORM code introduce a whole set of hard questions and decisions. Very few people expect ORM code to properly play with hand-coded-SQL. If you need to switch back to SQL, you are generally on your own.&lt;p&gt;&amp;gt; They&amp;#x27;ve somehow managed to make it too simple and too complex at the same time! Oh, and don&amp;#x27;t expect to just click a few jump to definitions an make sense of the ORM&amp;#x27;s inner code easily, god forbid :|...&lt;p&gt;It&amp;#x27;s simple to use, yet have complex internals. That&amp;#x27;s about what I would expect from a tool abstracting something complicated.</text></comment>
<story><title>ORMs Are Backwards</title><url>https://abe-winter.github.io/2019/09/03/orms-backwards.html</url></story><parent_chain><item><author>nnq</author><text>...you&amp;#x27;re the &lt;i&gt;ONLY&lt;/i&gt; person I saw with a good opinion of Django&amp;#x27;s ORM. I&amp;#x27;m willing to accept you could be right in preferring it, but:&lt;p&gt;&lt;i&gt;Could you share some resources of using it properly for advanced use cases? Good cookbooks etc.&lt;/i&gt;&lt;p&gt;For, it&amp;#x27;s always been a huge footgun, coupled with Python&amp;#x27;s dynamic nature, it&amp;#x27;s and endless source of bug after bug... Mistype a property on a model instance - no problem, no error, it will just not get saved to the db and data will be lost. Use progres native json and array fields - good luck running your tests on sqlite, the ORM that was helpful up to here just gives up and tells you &amp;quot;f u buddy, you&amp;#x27;re on your own&amp;quot;. Need to write complex hand-coded-sql queries that return complicated data, but you&amp;#x27;s still want to be able to serialize them into a graph of objects that can then be modified by regular ORM code - good luck with that, nobody cared about this scenario.&lt;p&gt;&lt;i&gt;They&amp;#x27;ve somehow managed to make it too simple and too complex at the same time! Oh, and don&amp;#x27;t expect to just click a few jump to definitions an make sense of the ORM&amp;#x27;s inner code easily, god forbid :|...&lt;/i&gt;&lt;p&gt;While I like the &lt;i&gt;idea of ORMs&lt;/i&gt;, I found them all &lt;i&gt;totally &amp;quot;wrong headed&amp;quot;&lt;/i&gt; And SQLAlchemy - that&amp;#x27;s just not worth the effort of learning to use it properly despite its good ideas, if you&amp;#x27;re only going to end up using 10% of its functionality and in an idiosyncratic way that was not intended.</text></item><item><author>bayesian_horse</author><text>I have a lot of experience with the Django ORM, but no other.&lt;p&gt;So I disagree with most points.&lt;p&gt;The Django ORM does map pretty neatly to SQL (in my opinion), and especially Postgres. The migration tool is anything but &amp;quot;half-baked&amp;quot;. And I have observed that beginners have an easier time creating Django models than dealing with straight SQL.&lt;p&gt;On top of that, the Django ORM mitigates most SQL injection attacks out of the box, without even requiring the developer to know about SQL injections in the first place.&lt;p&gt;And the ORM enables elegant code reuse by constructing query objects that can be used in Template logic, Form validation, generic CRUD, REST endpoints and more.&lt;p&gt;I agree that most ORMs don&amp;#x27;t help you with multiple programming languages. Though both the Django ORM and SQLAlchemy allow to customize a lot of the naming conventions and can be adapted to any legacy schema.&lt;p&gt;But then again: Is it even a good idea to access the same database from two codebases at all?&lt;p&gt;Some of the concerns about &amp;quot;ORMs kill the SQL-star&amp;quot; can be boiled down to a lack of a general understanding of relational databases in developers who learn to use an ORM before diving deeper into the philosophy of relational databases.</text></item></parent_chain><comment><author>andybak</author><text>&amp;gt; ...you&amp;#x27;re the ONLY person I saw with a good opinion of Django&amp;#x27;s ORM. I&amp;#x27;m willing to accept you could be right in preferring it,&lt;p&gt;No, he&amp;#x27;s not. Almost the entire Django community has a good opinion of it.&lt;p&gt;The main criticisms I see of Django&amp;#x27;s ORM seems to be from people that prefer SQLAlchemy. They have different design philosophys and the distinction seems largely a matter of taste and differing use-cases.</text></comment>