Hello all,
I am having problems with a query by an association(collection) using the
two alternatives described in documentation (
http://datamapper.org/docs/find.html).
Does anyone have any suggestions without writing a custom SQL query? (mysql
5.*, dm-* 1.2)
1. Order.all(:limit=>20, Order.order_lines.color=>'blue')
# by query path; this makes an inner join and returns *multiple orders* if
more than one blue order_line exist in each order. But i need unique list
of orders.
2. Order.all(:limit=>20, :order_lines=>{:color=>'blue'})
# by association hash; this makes 2 queries to the mysql; it first selects
all orders.id from order_lines (10 millions) with
# SELECT `order_id` FROM `order_lines` WHERE `order_id` = 'blue'
# and then queries orders table with "FROM orders where id in (12 1232
2323....)" with around a million blue item ids!!
Notes
a) When attempting a where clause with IN subquery,I saw this;
#http://datamapper.lighthouseapp.com/projects/20609/tickets/1330-dm-doesnt-handle-sub-selects-properly
b) DISTINCT(expenses.id) type of construct seems to be unsupported.
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/datamapper.
For more options, visit https://groups.google.com/groups/opt_out.