The sql works in MySql at least.

With the following two models, in different databases:

class Item < Sequel::Model(:sonar__tbltree)   many_to_one :customer,
:class=>:Customer, :key=>:customerid
end
class Customer < Sequel::Model(:samm__tblorganisation)   one_to_many :items,
:class=>:Item, :key=>:customerid
end

I can get my dataset:
dataset = Item.
  eager_graph(:customer).
  # select(:tbltree__id,:customer__name).
  order(:customer__name).
  limit(10)

and traverse it as two models:

dataset.all.each do |item|
  if item.customer.nil?
    p item.id
  else
    p item.id, item.customer.name
  end
end

This works fine, I get 10 rows with two columns each:
"15437 WSP Sverige AB"
"15418 WSP Sverige AB"
"15400 WSP Sverige AB"
"15377 WSP Sverige AB"
"15376 WSP Sverige AB"
"15375 WSP Sverige AB"
"15357 WSP Sverige AB"
"15298 WSP Sverige AB"
"15290 WSP Sverige AB"
"15283 WSP Sverige AB"
(2.656 secs)

But, if I try to reduce the number of columns, for performance, by reducing
the number of columns (from 45) to two

select(:tbltree__id,:customer__name)

I lose one column:

15437 15418
15400
15377
15376
15375
15357
15298
15290
15283
(0.125 secs)

The generated sql:

SELECT `tbltree`.`id`, `customer`.`name`
FROM `tbltree`
LEFT OUTER JOIN `samm`.`tblorganisation` AS `customer` ON (`customer`.`id` =
`tbltree`.`customerid`)
ORDER BY `customer`.`name` DESC, `tbltree`.`id` DESC
LIMIT 10

It seems item.customer is only updated when "select *" is used.

Have I found a limitation or am I doing something wrong here?

Christer

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to