Fetch clause suppresses where clause if positioned before Select clause

Description

Fetch clause AFTER Select:

Linq<InvoiceItem>().Where(ii => ii.Invoice.ID == id).Select(ii => ii).Fetch(ii => ii.Product).ToList();

Leads to

select * from invoice_items invoiceite0_
inner join invoices invoice1_
on invoiceite0_.[invoice_id] = invoice1_.[invoice_id]
left outer join products product2_
on invoiceite0_.[product_id] = product2_.[product_id]
where invoice1_.[invoice_id] = 51361

-> Correct, although the join on invoices seems superfluous, as the filtering could happen on the foreign key of invoice_items.

Fetch clause BEFORE Select:

Linq<InvoiceItem>().Where(ii => ii.Invoice.ID == id).Fetch(ii => ii.Product).Select(ii => ii).ToList();

leads to

select * from invoice_items invoiceite0_ left outer join products product1_ on invoiceite0_.[product_id] = product1_.[product_id]

-> Where clause is missing!

Environment

None

Activity

Show:
Alex Zaytsev
June 4, 2012, 8:00 PM

Fix commited to master 6195424ffa3f1cb884a6983e847e26dcb45f4859

Alex Zaytsev
June 4, 2012, 7:45 PM

What if select will change the edge?

Linq<InvoiceItem>().Where(ii => ii.Invoice.ID == id).Fetch(ii => ii.Product).Select(ii => ii.OtherEdge).ToList();

Fixed

Assignee

Alex Zaytsev

Reporter

Stefan Landgraf

Labels

Components

Fix versions

Affects versions

Priority

Major