<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: The more I have to hack ActiveRecord&#8217;s guts</title>
	<atom:link href="http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/</link>
	<description></description>
	<pubDate>Tue, 18 Nov 2008 09:24:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: matthew</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1540</link>
		<dc:creator>matthew</dc:creator>
		<pubDate>Thu, 20 Dec 2007 11:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1540</guid>
		<description>Anthony - nope I didn't catch the keynote, although saying "x does what it was designed to do, and if you don't like it use something else" doesn't have a ton of useful content for me.

My issue with ActiveRecord is that I feel it's being pushed too far beyond what it's capable of and suited for, both by the ActiveRecord developers, and by a lot of the Rails projects using it. Perhaps making people more aware that other more elegant approaches exist to the data layer, and what the trade-offs are, would help.

Mark - my thoughts on graph-based models (RDF is one) - they are just a restricted form of a highly-normalised relational model, where you're restricted to binary predicates/relations corresponding to different kinds of labels for graph edges. Often you want ternary and higher predicates, even in a highly normalised relational model - forcing them to be binary is only possible if you introduce arbitrary surrogate objects into your graph to represent the rows of greater=than-binary relations. I guess that's not always an issue, but I prefer the more relational model myself.

It seems that with the relational model you have a lot more scope to index things efficiently for particular queries (using multi-column indices, indexed views etc), to impose structure in the form of (potentially multi-column) uniqueness and foreign key constraints. While I expect similar ends could be acheived by a sophisticated graph-based DBMS, I'm not sure I've seen anything yet capable of it.

I hear good things about this project: http://rubyforge.org/projects/activefacts/
and will be following that quite closely</description>
		<content:encoded><![CDATA[<p>Anthony - nope I didn&#8217;t catch the keynote, although saying &#8220;x does what it was designed to do, and if you don&#8217;t like it use something else&#8221; doesn&#8217;t have a ton of useful content for me.</p>
<p>My issue with ActiveRecord is that I feel it&#8217;s being pushed too far beyond what it&#8217;s capable of and suited for, both by the ActiveRecord developers, and by a lot of the Rails projects using it. Perhaps making people more aware that other more elegant approaches exist to the data layer, and what the trade-offs are, would help.</p>
<p>Mark - my thoughts on graph-based models (RDF is one) - they are just a restricted form of a highly-normalised relational model, where you&#8217;re restricted to binary predicates/relations corresponding to different kinds of labels for graph edges. Often you want ternary and higher predicates, even in a highly normalised relational model - forcing them to be binary is only possible if you introduce arbitrary surrogate objects into your graph to represent the rows of greater=than-binary relations. I guess that&#8217;s not always an issue, but I prefer the more relational model myself.</p>
<p>It seems that with the relational model you have a lot more scope to index things efficiently for particular queries (using multi-column indices, indexed views etc), to impose structure in the form of (potentially multi-column) uniqueness and foreign key constraints. While I expect similar ends could be acheived by a sophisticated graph-based DBMS, I&#8217;m not sure I&#8217;ve seen anything yet capable of it.</p>
<p>I hear good things about this project: <a href="http://rubyforge.org/projects/activefacts/" rel="nofollow">http://rubyforge.org/projects/activefacts/</a><br />
and will be following that quite closely</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1461</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 03 Dec 2007 07:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1461</guid>
		<description>Hi very interesting blog - thanks.

Are there still plans for a new ORM project?
By doing ORM right did you have in mind something like what is described here (implmented in Ruby of course):

http://rubyurl.com/0DB

Some of the initial heavy lifting for which would probably be made easier by gratr:

http://gratr.rubyforge.org/

Thanks again.</description>
		<content:encoded><![CDATA[<p>Hi very interesting blog - thanks.</p>
<p>Are there still plans for a new ORM project?<br />
By doing ORM right did you have in mind something like what is described here (implmented in Ruby of course):</p>
<p><a href="http://rubyurl.com/0DB" rel="nofollow">http://rubyurl.com/0DB</a></p>
<p>Some of the initial heavy lifting for which would probably be made easier by gratr:</p>
<p><a href="http://gratr.rubyforge.org/" rel="nofollow">http://gratr.rubyforge.org/</a></p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Green</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1356</link>
		<dc:creator>Anthony Green</dc:creator>
		<pubDate>Tue, 13 Nov 2007 12:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1356</guid>
		<description>I was wondering if you caught Martin Fowler's keynote at RailsConf 2006 ? (Its still available as a podcast on Odeo if you didn't). My interpretation of that speech is that Rails' ActiveRecord does exactly what its supposed to do. That is, if you want to write an application similar to Basecamp - the project from which it was extracted. However if thats not how you model your world then you need something else.</description>
		<content:encoded><![CDATA[<p>I was wondering if you caught Martin Fowler&#8217;s keynote at RailsConf 2006 ? (Its still available as a podcast on Odeo if you didn&#8217;t). My interpretation of that speech is that Rails&#8217; ActiveRecord does exactly what its supposed to do. That is, if you want to write an application similar to Basecamp - the project from which it was extracted. However if thats not how you model your world then you need something else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthew</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1001</link>
		<dc:creator>matthew</dc:creator>
		<pubDate>Fri, 19 Oct 2007 12:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1001</guid>
		<description>ActiveRecord is fairly loosely coupled to the rest of Rails actually. The scaffolding and some of the form creation helpers are a bit coupled to it, although will work with something similarly duck-typed too.

ActiveRelation - just checked and, ouch, it's still using CVS, which was the only option at the time :/

cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/active-relation checkout active-relation

should do the trick. I have actually used it in a rails app in place of activerecord - but for maintainability reasons it would be nice to have something which is reasonably accessible to all the Rails folk out there with activerecord experience...</description>
		<content:encoded><![CDATA[<p>ActiveRecord is fairly loosely coupled to the rest of Rails actually. The scaffolding and some of the form creation helpers are a bit coupled to it, although will work with something similarly duck-typed too.</p>
<p>ActiveRelation - just checked and, ouch, it&#8217;s still using CVS, which was the only option at the time :/</p>
<p>cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/active-relation checkout active-relation</p>
<p>should do the trick. I have actually used it in a rails app in place of activerecord - but for maintainability reasons it would be nice to have something which is reasonably accessible to all the Rails folk out there with activerecord experience&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley Moran</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1000</link>
		<dc:creator>Ashley Moran</dc:creator>
		<pubDate>Fri, 19 Oct 2007 11:49:51 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-1000</guid>
		<description>I imagine the session-based system makes it easier to spec too, so you can mock the session instead of stubbing MyModel.find... I shudder every time I do that.

I don't see why, if you had a full mapping system like SQLAlchemy, you couldn't write a facade layer that makes it look like ActiveRecord by generating default classtable mappers at some point in the app lifecycle.  Although TBH, I am not immediately very concerned with making it a drop-in replacement for ActiveRecord, as I think most Rails developers want to use everything out of the box.  (And I don't know how loosely-coupled AR is to Rails anyway.)

I have actually already registered a project (not accepted yet) called Celestial - there's prize for the first person to figure out the pun :)

Couldn't find the ActiveRelation source you mention on RubyForge, all I can find is the home page.</description>
		<content:encoded><![CDATA[<p>I imagine the session-based system makes it easier to spec too, so you can mock the session instead of stubbing MyModel.find&#8230; I shudder every time I do that.</p>
<p>I don&#8217;t see why, if you had a full mapping system like SQLAlchemy, you couldn&#8217;t write a facade layer that makes it look like ActiveRecord by generating default classtable mappers at some point in the app lifecycle.  Although TBH, I am not immediately very concerned with making it a drop-in replacement for ActiveRecord, as I think most Rails developers want to use everything out of the box.  (And I don&#8217;t know how loosely-coupled AR is to Rails anyway.)</p>
<p>I have actually already registered a project (not accepted yet) called Celestial - there&#8217;s prize for the first person to figure out the pun <img src='http://blog.playlouder.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Couldn&#8217;t find the ActiveRelation source you mention on RubyForge, all I can find is the home page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthew</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-998</link>
		<dc:creator>matthew</dc:creator>
		<pubDate>Fri, 19 Oct 2007 10:59:23 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-998</guid>
		<description>Actually looking back at it, ActiveRelation isn't really what I want any more. But something like it could form the relational layer for a more fully-featured ORM.</description>
		<content:encoded><![CDATA[<p>Actually looking back at it, ActiveRelation isn&#8217;t really what I want any more. But something like it could form the relational layer for a more fully-featured ORM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthew</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-997</link>
		<dc:creator>matthew</dc:creator>
		<pubDate>Fri, 19 Oct 2007 10:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-997</guid>
		<description>Yeah it's nice isn't it. I've used it on a Python project, and while the session-based approach takes a little getting used to, the sheer power of the thing really astounds.

I was thinking of attempting something which aims to feel at least superficially familiar to ActiveRecord users - but which has a proper relational layer under the hood and allows for various different ways of mapping class inheritance hierarchies and mixins to relations. Ideally allowing for better approaches to polymorphic associations too, and for a nice ruby-like query-building syntax.

I'd probably want it to use the SQLAlchemy database session approach too - in a Rails app one session for request would make a lot of sense. The way it identifies the database changes needed to 'flush' an set of changes to the object graph, topologically sorts them by foreign key dependency and executes them in a nice transaction... lovely.

Also the way there is only ever one Object present in memory per row of a relation.

Maybe we should start a rubyforge project!

If you're interested, this could be used as a starting-point - something I put together a long time ago for ruby:

http://rubyforge.org/projects/active-relation/

the only source code is in the SVN repository on rubyforge..</description>
		<content:encoded><![CDATA[<p>Yeah it&#8217;s nice isn&#8217;t it. I&#8217;ve used it on a Python project, and while the session-based approach takes a little getting used to, the sheer power of the thing really astounds.</p>
<p>I was thinking of attempting something which aims to feel at least superficially familiar to ActiveRecord users - but which has a proper relational layer under the hood and allows for various different ways of mapping class inheritance hierarchies and mixins to relations. Ideally allowing for better approaches to polymorphic associations too, and for a nice ruby-like query-building syntax.</p>
<p>I&#8217;d probably want it to use the SQLAlchemy database session approach too - in a Rails app one session for request would make a lot of sense. The way it identifies the database changes needed to &#8216;flush&#8217; an set of changes to the object graph, topologically sorts them by foreign key dependency and executes them in a nice transaction&#8230; lovely.</p>
<p>Also the way there is only ever one Object present in memory per row of a relation.</p>
<p>Maybe we should start a rubyforge project!</p>
<p>If you&#8217;re interested, this could be used as a starting-point - something I put together a long time ago for ruby:</p>
<p><a href="http://rubyforge.org/projects/active-relation/" rel="nofollow">http://rubyforge.org/projects/active-relation/</a></p>
<p>the only source code is in the SVN repository on rubyforge..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley Moran</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-990</link>
		<dc:creator>Ashley Moran</dc:creator>
		<pubDate>Thu, 18 Oct 2007 22:33:42 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-990</guid>
		<description>I don't think the DB migration thing would be as hard as it sounds in the simple case, it only has to be aware of certain conflicting operations, and be able to draw up a dependency tree (which, to simplify matters further, can be largely manually specified).  Then the migration tool only has to record unapplied patches (determined by querying a list in the database, as opposed to a version number).

Aqua Data Studio has schema and data diffing tools, but personally I'd advise against going down that route.  It was how development used to be done at my current company before I started, and Database Diff Day was often a marathon event.  I think the best way is to have a lightweight repeatable migration system, so you can easily snapshot, migrate and restore your dev DB (easier than fixing broken down steps).  One thing that is missing from the process is migration-BDD - I'd love to have a way of writing specs for database state post-migration, but in a multi-developer environment that would just be intractable.

I'd only given SQLAlchemy a brief look over before, but I've just gone through most of the tutorial and I'm blown away!  I am so tempted to start porting it - I have a feeling it may be quite easy to get some of the basics working, as the code looks very loosely coupled.  I may investigate it over the weekend, and sketch out the architecture.  If I think I can have something useful working in under two months, I may well make a start.  It's about time the Ruby world had a decent ORM, damnit!</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think the DB migration thing would be as hard as it sounds in the simple case, it only has to be aware of certain conflicting operations, and be able to draw up a dependency tree (which, to simplify matters further, can be largely manually specified).  Then the migration tool only has to record unapplied patches (determined by querying a list in the database, as opposed to a version number).</p>
<p>Aqua Data Studio has schema and data diffing tools, but personally I&#8217;d advise against going down that route.  It was how development used to be done at my current company before I started, and Database Diff Day was often a marathon event.  I think the best way is to have a lightweight repeatable migration system, so you can easily snapshot, migrate and restore your dev DB (easier than fixing broken down steps).  One thing that is missing from the process is migration-BDD - I&#8217;d love to have a way of writing specs for database state post-migration, but in a multi-developer environment that would just be intractable.</p>
<p>I&#8217;d only given SQLAlchemy a brief look over before, but I&#8217;ve just gone through most of the tutorial and I&#8217;m blown away!  I am so tempted to start porting it - I have a feeling it may be quite easy to get some of the basics working, as the code looks very loosely coupled.  I may investigate it over the weekend, and sketch out the architecture.  If I think I can have something useful working in under two months, I may well make a start.  It&#8217;s about time the Ruby world had a decent ORM, damnit!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthew</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-984</link>
		<dc:creator>matthew</dc:creator>
		<pubDate>Thu, 18 Oct 2007 11:35:03 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-984</guid>
		<description>Ooh, an SQLAlchemy port would be very nice. heh.

I did look into Og briefly - does seems a bit better than ActiveRecord but still the same approach.

The DB migration tool sounds like quite a challenge - can't say it's ever been enough of an issue for me to really feel the need, although I've not had to deal with significant concurrent database work with other developers - just the occasional 'two different migrations get created and committed with the same number' issue.

What would be nice would be a SQL-specific diff tool which could generate migrations from a before and after schema - perhaps integrated into the version control system. But that would only handle changes to the schema, and schema migrations often need to be done alongside (or interleaved with) data migrations (insert/delete/update etc). So I suspect it's fundamentally quite a hard problem.</description>
		<content:encoded><![CDATA[<p>Ooh, an SQLAlchemy port would be very nice. heh.</p>
<p>I did look into Og briefly - does seems a bit better than ActiveRecord but still the same approach.</p>
<p>The DB migration tool sounds like quite a challenge - can&#8217;t say it&#8217;s ever been enough of an issue for me to really feel the need, although I&#8217;ve not had to deal with significant concurrent database work with other developers - just the occasional &#8216;two different migrations get created and committed with the same number&#8217; issue.</p>
<p>What would be nice would be a SQL-specific diff tool which could generate migrations from a before and after schema - perhaps integrated into the version control system. But that would only handle changes to the schema, and schema migrations often need to be done alongside (or interleaved with) data migrations (insert/delete/update etc). So I suspect it&#8217;s fundamentally quite a hard problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley Moran</title>
		<link>http://blog.playlouder.com/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-977</link>
		<dc:creator>Ashley Moran</dc:creator>
		<pubDate>Wed, 17 Oct 2007 21:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://devblog.playlouder.com/index.php/2007/10/17/the-more-i-have-to-hack-the-guts-of-activerecord/#comment-977</guid>
		<description>Hmmm...

    ~/Desktop/sqlalchemy-trunk ashleymoran$ wc -l `find . -name '*.py'`
        ...
    70898 total

If I get cracking, might have it ported by xmas 2009...

However 2566 lines of that is for MySQL, which can be removed straight away ;o)</description>
		<content:encoded><![CDATA[<p>Hmmm&#8230;</p>
<p>    ~/Desktop/sqlalchemy-trunk ashleymoran$ wc -l `find . -name &#8216;*.py&#8217;`<br />
        &#8230;<br />
    70898 total</p>
<p>If I get cracking, might have it ported by xmas 2009&#8230;</p>
<p>However 2566 lines of that is for MySQL, which can be removed straight away ;o)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
