Ruby Datamapper留下了外连接

时间:2011-12-07 16:25:31

标签: ruby datamapper

有没有办法在Datamapper中执行左外连接,而无需直接与数据存储进行通信。我一直在搜索网络和Datamapper文档但没有成功详细说明如何操作。

1 个答案:

答案 0 :(得分:0)

看起来严格的左外连接是相当困难的。

查看网站:

68 # QueryPaths can be used to construct joins in a very declarative manner.
69 #
70 # Starting from a root model, you can call any relationship by its name.
71 # The returned object again responds to all property and relationship names
72 # that are defined in the relationship's target model.
73 #
74 # This means that you can walk the chain of available relationships, and       then
75 # match against a property at the end of that chain. The object returned by
76 # the last call to a property name also responds to all the comparison
77 # operators available in traditional queries. This makes for some powerful
78 # join construction!
79 #
80 Customer.all(Customer.orders.order_lines.item.sku.like => "%BLUE%")

查看docs,看起来Query类有一个知道外键的关系处理程序。