Hi all, This seems like a plugin conflict (I haven''t yet had success replicating this in a new project), but short version is: when I have "rspec-rails" in my environment.rb plugin config, table names are double quoted in mysql queries generated by my standard finders. rspec-rails commented out: SELECT * FROM `users` WHERE (`users`.`id` = ''159564615'') LIMIT 1 rspec-rails in enviroment.rb gem config: SELECT * FROM "users" WHERE ("users"."id" = ''159564615'') LIMIT 1 The double quotes break the SQL, and so no objects are returned from my queries. This happened after I updated to 1.2.9 gem versions when I couldn''t get cucumber (0.4.4) to look for git submodules in my project. Any ideas? I''m pretty lost at the moment, and don''t want to run without rspec (it makes me feel neked). Short version of my required gems: cucumber (0.4.4) mysql (2.8.1) rails (2.3.4) rspec (1.2.9) rspec-rails (1.2.9) /Dave -- Posted via http://www.ruby-forum.com/.
Forgot to mention: I''d love to track this down myself, but i''m not getting a backtrace as there is no error (just no results). Point me in the right direction and I''ll do what I can to solve this. -- Posted via http://www.ruby-forum.com/.
David Nawara
2009-Nov-18 18:39 UTC
[rspec-users] rspec-rails gem changing connection adapter
This thread should be titled: "rspec-rails gem changing connection adapter?" I did some puts''s and found that something is changing the connection adapter to ActiveRecord::ConnectionAdapters::SQLite3Adapter, from my specified ActiveRecord::ConnectionAdapters::MysqlAdapter. Or maybe it''s causing my connection settings not to apply? Still not sure if I''m barking up the wrong tree, but the problem still does fix itself when i comment out my rspec-rails gem. -- Posted via http://www.ruby-forum.com/.
Matt Wynne
2009-Nov-18 19:22 UTC
[rspec-users] rspec-rails gem changing connection adapter
On 18 Nov 2009, at 18:39, David Nawara wrote:> This thread should be titled: "rspec-rails gem changing connection > adapter?" > > I did some puts''s and found that something is changing the connection > adapter to ActiveRecord::ConnectionAdapters::SQLite3Adapter, from my > specified ActiveRecord::ConnectionAdapters::MysqlAdapter. Or maybe > it''s > causing my connection settings not to apply? > > Still not sure if I''m barking up the wrong tree, but the problem still > does fix itself when i comment out my rspec-rails gem.Which version of the rspec-rails gem are you using? Can you check the value of RAILS_ENV before and after the connection adapter gets changed? There are plugins and various other things (including an old version of rspec-rails) that stomp on RAILS_ENV when they load. That might be the problem. cheers, Matt +447974 430184 matt at mattwynne.net http://mattwynne.net
David Nawara
2009-Nov-18 19:34 UTC
[rspec-users] rspec-rails gem changing connection adapter
Yeah I think you''re right. I''m working on this now... I noticed the only RAILS_ENV I have set on sqlite is the test environment (in database.yml), and cucumber is now doing some ||= fun on the RAILS_ENV, so I''m following that trail. I suspect something (cucumber?) is setting me to the test or cucumber RAiLS_ENV. Thanks for the post! Matt Wynne wrote:> On 18 Nov 2009, at 18:39, David Nawara wrote: > >> does fix itself when i comment out my rspec-rails gem. > Which version of the rspec-rails gem are you using? > > Can you check the value of RAILS_ENV before and after the connection > adapter gets changed? There are plugins and various other things > (including an old version of rspec-rails) that stomp on RAILS_ENV when > they load. That might be the problem. > > cheers, > Matt > > +447974 430184 > matt at mattwynne.net > http://mattwynne.net-- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Nov-18 20:07 UTC
[rspec-users] rspec-rails gem double quoting (My)SQL?
On Tue, Nov 17, 2009 at 3:04 PM, David Nawara <lists at ruby-forum.com> wrote:> Hi all, > > This seems like a plugin conflict (I haven''t yet had success replicating > this in a new project), but short version is: when I have "rspec-rails" > in my environment.rb plugin config, table names are double quoted in > mysql queries generated by my standard finders. > > rspec-rails commented out: > > SELECT * FROM `users` WHERE (`users`.`id` = ''159564615'') LIMIT 1 > > rspec-rails in enviroment.rb gem config: > > SELECT * FROM "users" WHERE ("users"."id" = ''159564615'') LIMIT 1 > > The double quotes break the SQL, and so no objects are returned from my > queries. This happened after I updated to 1.2.9 gem versions when I > couldn''t get cucumber (0.4.4) to look for git submodules in my project. > > Any ideas? I''m pretty lost at the moment, and don''t want to run without > rspec (it makes me feel neked). > > Short version of my required gems: > > cucumber (0.4.4) > mysql (2.8.1) > rails (2.3.4) > rspec (1.2.9) > rspec-rails (1.2.9) > > > /DaveI really don''t think this is an rspec-rails issue, though I''m certainly happy to apply a patch if I''m wrong. The thing is that there is no code that I''m aware of in the rspec-rails gem that would impact what sql is generated. If you can find a way to repeat the error and zip up an app for me to look at I''d be glad to. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091118/0c171bb7/attachment.html>
David Nawara
2009-Nov-18 20:08 UTC
[rspec-users] rspec-rails gem changing connection adapter
I''m not totally there, but I''m pretty sure it''s down to the authlogic plugin. Thanks for your help, and sorry about the misfire on rspec. (I didn''t think that one made sense, but it''s all I had at the time.) I''ve actually found I can comment out loading observers in my environment.rb and things will work, or i can remove my acts_as_authentic tag on my users and I''m OK. I''m mostly certain it''s a plugin load order thing kicking me to the test environment. Regards, David -- Posted via http://www.ruby-forum.com/.
In case anyone feels like messing with this, I''ve replicated the problem in a minimal test application... The problem seems to be some sort of load issue. From what I can tell, it is due to three related items: 1) a user model with authlogic, 2) rspec-rails, and 3) a users observer. Removing any one of the three seems to "fix" the issue. I''ve noted the lines which you can comment out to see the problem resolve. (It should then load the development SQLite3 database with my test user). The visible symptom is:> SQLite3::SQLException: no such table: users: SELECT * FROM "users"Apparently the conflict pushes the app into the test environment. Gems: - authlogic 2.1.3 - rspec and rspec-rails 1.2.9 - rails 2.3.4 I''m on passenger 2.2.5, and I hope that''s not a factor. I currently run stock Snow Leopard ruby. Any clue how I can further track this down? I don''t see anything obvious with either rspec or authlogic fudging with the environment? Regards, David Nawara PS - I think I''ll go post this in an authlogic forum now. Attachments: http://www.ruby-forum.com/attachment/4263/testapp.tgz -- Posted via http://www.ruby-forum.com/.
The problem goes away when I ditch the gems and grab the plugins off github. (The archive is too large, or I''d upload that version.) Now I just have to get cucumber working with plugins, which is the reason I switched to gems in the first place? -- Posted via http://www.ruby-forum.com/.