Bug 891865

Summary: sqlite 3.7.15 breaks ActiveRecord (Ruby on Rails) test suite
Product: [Fedora] Fedora Reporter: Vít Ondruch <vondruch>
Component: sqliteAssignee: Panu Matilainen <pmatilai>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: pmatilai, wilmer5
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-14 09:58:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vít Ondruch 2013-01-04 09:21:50 UTC
Description of problem:
sqlite 3.7.15 breaks ActiveRecord (Ruby on Rails) test suite

Version-Release number of selected component (if applicable):
$ rpm -q sqlite
sqlite-3.7.15-1.fc19.x86_64

How reproducible:
Always


Steps to Reproduce:
1. $ git clone https://github.com/rails/rails.git
2. $ cd rails/activerecord
3. $ ruby -I.:test:lib test/cases/associations/nested_through_associations_test.rb
  
Actual results:
$ rpm -q sqlite
sqlite-3.7.15-1.fc19.x86_64
$ ruby -I.:test:lib test/cases/associations/nested_through_associations_test.rb

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

Using sqlite3 with Identity Map off
Run options: 

# Running tests:

.F.........F.............................................

Finished tests in 1.205003s, 47.3028 tests/s, 132.7797 assertions/s.

  1) Failure:
test_distinct_has_many_through_a_has_many_through_association_on_through_reflection(NestedThroughAssociationsTest) [test/cases/associations/nested_through_associations_test.rb:393]:
<[#<Subscriber nick: "alterself", name: "Luke Holden", books_count: 0>,
 #<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>]> expected but was
<[#<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>, #<Subscriber nick: "alterself", name: "Luke Holden", books_count: 0>]>.

  2) Failure:
test_has_many_through_has_many_through_with_has_many_source_reflection(NestedThroughAssociationsTest) [test/cases/associations/nested_through_associations_test.rb:82]:
<[#<Subscriber nick: "alterself", name: "Luke Holden", books_count: 0>,
 #<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>,
 #<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>]> expected but was
<[#<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>, #<Subscriber nick: "webster132", name: "David Heinemeier Hansson", books_count: 0>, #<Subscriber nick: "alterself", name: "Luke Holden", books_count: 0>]>.

57 tests, 160 assertions, 2 failures, 0 errors, 0 skips

Expected results:
$ rpm -q sqlite
sqlite-3.7.14.1-1.fc19.x86_64
$ ruby -I.:test:lib test/cases/associations/nested_through_associations_test.rb

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

Using sqlite3 with Identity Map off
Run options: 

# Running tests:

.........................................................

Finished tests in 1.132622s, 50.3257 tests/s, 141.2651 assertions/s.

57 tests, 160 assertions, 0 failures, 0 errors, 0 skips

Additional info:
I have opened ticket in Ruby on Rails issue tracker first: https://github.com/rails/rails/issues/8724

Since I am not following sqlite development, I'd appreciate your help with solving this issue.

Also, I am afraid that this might have negative impact on other SW using sqlite, so I am not sure if revert should not be considered.

Comment 1 Panu Matilainen 2013-01-11 10:59:38 UTC
I've a feeling this might be fixed in 3.7.15.2 (built for rawhide yesterday, or in koji http://koji.fedoraproject.org/koji/taskinfo?taskID=4854807):

"Fix a bug, introduced in version 3.7.15, that causes an ORDER BY clause to be optimized out of a three-way join when the ORDER BY is actually required. Ticket 598f5f7596b055"

Can you test with the new version? The reproducer doesn't work for me, I'm probably missing some other ruby bits on my system but I'm pretty clueless when it comes to ruby...

Comment 2 Vít Ondruch 2013-01-14 09:06:44 UTC
Thank you for heads up. It works now.

Comment 3 Panu Matilainen 2013-01-14 09:58:22 UTC
Okay, thanks for confirming.