开发者

What might this be: New Active Record chainable query language built on top of relational algebra?

I saw this on a blo开发者_运维问答g today, and I thought, finally! Rails will have something like HQL or Linq. Um, or not. I couldn't find anything about this.

What I really want to know: will I be able to forget what the tables are called and use the object names only? Can I finally forget join syntax? I'd like to do that before I start forgetting everything else (life goals).


As far as I understand, this means that you can write your complex queries not as

Object.find(:all, :conditions = > { :limit => 10, :offset => 5 }

but more readable way

Object.all.limit(10).offset(5)


Chainable queries with lazy evaluation and the AREL syntax:

This lets you write various scopes representing conditions and then mix and match them and chain them together... in the knowledge the the query will not actually get run until the output is needed ('lazy evaluation').

The syntax of AREL is much closer to standard sql syntax instead of the previous 'rails' syntax so it is easier to use and recognize and maintain for those famiiar with SQL.


You can read more about it here. I'm not terribly familiar with LINQ, but I believe LINQ is somewhat similar to the query interface used by Django's ORM. At any rate, the gist is that the query interface in Active Record is more like that of Django that it was before. A lot of the older "low-level" query methods are deprecated and will be removed in later versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜