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
on 2009-11-18 00:04
on 2009-11-18 00:10
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.
on 2009-11-18 19:39
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.
on 2009-11-18 20:31
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@mattwynne.net http://mattwynne.net
on 2009-11-18 20:34
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@mattwynne.net > http://mattwynne.net
on 2009-11-18 21:08
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
on 2009-11-18 21:15
On Tue, Nov 17, 2009 at 3:04 PM, David Nawara <lists@ruby-forum.com> wrote: > > > 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 I 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
on 2009-11-18 23:17
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.
on 2009-11-19 21:27
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…
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.