I’m trying to track down a strange test error. This project has Rails
2.1.0
frozen in vendor/rails . On my MacBook Pro, the problem boils down to
this:
(rdb:1) Invoice.first(:order=>‘id desc’)
#<Invoice id: 3, type: “Invoice”, name: “Invoice 1 for Job 1”, memo:
nil,
created_at: “2007-09-03 00:00:00”, updated_at: “2009-03-30 16:49:48”,
est_inv_number: “1-03”, status: “free”, qb_txn_id: nil, per_quote:
false,
bill_to: nil, printed_at: nil, emailed_at: nil, faxed_at: nil,
invoiceable_type: “Job”, invoiceable_id: 1, qb_sent_at: nil, company_id:
850010094, itemize_tax_markup: false, bill_to_customer_id: nil,
qb_class_override: nil, proposal_loaded: false, proposal_date: nil,
proposal_re: nil, proposal_attn: nil, proposal_body: nil,
proposal_include:
nil, proposal_exclude: nil, proposal_sig: nil, date: “2007-09-03”>
(rdb:1) Invoice.find(:all, :order=>‘id desc’).first
#<Invoice id: 9, type: “Invoice”, name: “Estimate 1 for Job 1”, memo:
nil,
created_at: “2009-03-30 16:52:48”, updated_at: “2009-03-30 16:52:48”,
est_inv_number: “1-05”, status: “free”, qb_txn_id: nil, per_quote:
false,
bill_to: nil, printed_at: nil, emailed_at: nil, faxed_at: nil,
invoiceable_type: “Job”, invoiceable_id: 1, qb_sent_at: nil, company_id:
850010094, itemize_tax_markup: false, bill_to_customer_id: nil,
qb_class_override: nil, proposal_loaded: false, proposal_date: nil,
proposal_re: nil, proposal_attn: nil, proposal_body: nil,
proposal_include:
nil, proposal_exclude: nil, proposal_sig: nil, date: “2009-03-30”>
I’m in the debugger in the middle of a test run. I have another Mac,
running the same version of the code, checked out from the same
repository,
on which this works fine. The SQL queries produced for these two lines
is
identical on both machines:
Invoice Load (0.000516) SELECT * FROM est_invs
WHERE (
(est_invs
.type
= ‘Invoice’ ) ) ORDER BY id desc LIMIT 1
and
Invoice Load (0.000536) SELECT * FROM est_invs
WHERE (
(est_invs
.type
= ‘Invoice’ ) ) ORDER BY id desc
Here’s another way of looking at the same weirdness:
(rdb:1) Invoice.first.id http://invoice.first.id/
3
(rdb:1) Invoice.last.id http://invoice.last.id/
3
(rdb:1) Invoice.all.map(&:id)
[3, 4, 5, 6, 9]
(rdb:1) Invoice.all.first.id http://invoice.all.first.id/
3
(rdb:1) Invoice.all.last.id http://invoice.all.last.id/
9
On my other Mac, running the same code, same test, etc., it looks like
this
(which is how it should look):
(rdb:1) Invoice.first.id http://invoice.first.id/
3
(rdb:1) Invoice.last.id http://invoice.last.id/
9
(rdb:1) Invoice.all.map(&:id)
[3, 4, 5, 6, 9]
(rdb:1) Invoice.all.first.id http://invoice.all.first.id/
3
(rdb:1) Invoice.all.last.id http://invoice.all.last.id/
9
I can’t figure out what’s going on. I’ve been staring at this off and
on
for days, and I’m out of ideas. Anyone have any good ones?