I know that datasets always hit the database, but I don't think it  
should hit the db when it already knows the value of the primary key.  
Here's an example.

order = Order.create(:order_id => m[:order_id],
                              :date => gen_date(m[:date]),
                              :market => m[:market])

cache[:order_primary_key] = order.pk

This code results in two database hits like so:

I, [2007-11-16T13:15:11.468035 #1255]  INFO -- : INSERT INTO orders  
( `market`, `date`, `order_id`) VALUES ( 'ICE', '20071114', '9104')
I, [2007-11-16T13:15:11.468913 #1255]  INFO -- : SELECT * FROM orders  
WHERE (`id` = 28838) LIMIT 1

The order instance obviously already knows the primary key since it  
uses it for the SELECT statement.

I don't see anything obvious in the code for +pk+. It looks correct  
to me. Here's the code for +pk+.

def pk
   @pk ||= @values[:id]
end

Is this a bug? Shouldn't it return @pk directly since it already  
knows the value?



--~--~---------~--~----~------------~-------~--~----~
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