Matthew Palmer
2006-Jan-03 02:55 UTC
[Rails] in-memory test database -- where''s the schema?
I''m trying to get the unit testing for a new project to use the wonderful :memory: database specification for SQLite. However, like many people before me, I can''t get the schema to import or have anything else useful. Initially, the error I get is: /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/errors.rb:94:in `check'': cannot rollback - no transaction is active (SQLite3::SQLException) Since this error seems to be transaction related, I followed the advice from another post, and turned off transactional fixtures. That changed the error message to this: ActiveRecord::StatementInvalid: no such table: repositories: DELETE FROM repositories WHERE 1=1 Which certainly seems to suggest that no tables have been created in the memory database. In an attempt to discover whether what I want to do is actually possible, I grepped the source for :memory:. Some of the AR unit tests do appear to use an in-memory SQLite database, but they create the tables by hand from a definition file (ugh). Is there anyone who actually knows how this is supposed to work in Rails, and can provide helpful pointers as to it''s use? If not, may I suggest removing mention of it from the default database.yml file, to prevent confusion such as this in the future? - Matt -- English is about as pure as a cribhouse whore. We don''t just borrow words; on occasion, English has pursued other languages down alleyways to beat them unconscious and rifle their pockets for new vocabulary." -- James D. Nicoll, resident of rec.arts.sf.written
''me too'' - does anyone know if this used to work? I can''t see anything obvious in trac, but this was hosed in Rails 1.0 for me when I tried today (sqlite3). On 03/01/06, Matthew Palmer <mpalmer@hezmatt.org> wrote:> I''m trying to get the unit testing for a new project to use the wonderful > :memory: database specification for SQLite. However, like many people > before me, I can''t get the schema to import or have anything else useful. > > Initially, the error I get is: > > /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/errors.rb:94:in > `check'': cannot rollback - no transaction is active (SQLite3::SQLException) > > Since this error seems to be transaction related, I followed the advice from > another post, and turned off transactional fixtures. That changed the error > message to this: > > ActiveRecord::StatementInvalid: no such table: repositories: DELETE FROM > repositories WHERE 1=1 > > Which certainly seems to suggest that no tables have been created in the > memory database. > > In an attempt to discover whether what I want to do is actually possible, I > grepped the source for :memory:. Some of the AR unit tests do appear to use > an in-memory SQLite database, but they create the tables by hand from a > definition file (ugh). > > Is there anyone who actually knows how this is supposed to work in Rails, > and can provide helpful pointers as to it''s use? If not, may I suggest > removing mention of it from the default database.yml file, to prevent > confusion such as this in the future? > > - Matt > > -- > English is about as pure as a cribhouse whore. We don''t just borrow > words; on occasion, English has pursued other languages down alleyways > to beat them unconscious and rifle their pockets for new vocabulary." > -- James D. Nicoll, resident of rec.arts.sf.written > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/
Xavier Noria
2006-Jan-03 17:20 UTC
[Rails] in-memory test database -- where''s the schema?
On Jan 3, 2006, at 17:49, Dick Davies wrote:> ''me too'' - does anyone know if this used to work? > > I can''t see anything obvious in trac, but this was hosed in > Rails 1.0 for me when I tried today (sqlite3).I reported the same issue a while back to no avail. Could we maybe find out who committed the default in-memory for testing in the generated database.yml and see whether it worked for him? Unfortunately nobody seems to be able to test with ":memory:". -- fxn
Daniel Hackney
2006-Jan-03 23:58 UTC
[Rails] in-memory test database -- where''s the schema?
I have not really looked at the source all that closely (I am a Ruby n00by) but it seems that there is a problem somewhere between the parsing of the database.yml file and the passing of the :memory: parameter to sqlite. When SQLite is used like this: ActiveRecord::Base.establish_connection( :adapter => "sqlite", :database => ":memory:" ) it works beautifully. Hope that helps. Dan On 1/3/06, Xavier Noria <fxn@hashref.com> wrote:> On Jan 3, 2006, at 17:49, Dick Davies wrote: > > > ''me too'' - does anyone know if this used to work? > > > > I can''t see anything obvious in trac, but this was hosed in > > Rails 1.0 for me when I tried today (sqlite3). > > I reported the same issue a while back to no avail. > > Could we maybe find out who committed the default in-memory for > testing in the generated database.yml and see whether it worked for > him? Unfortunately nobody seems to be able to test with ":memory:". > > -- fxn > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Xavier Noria
2006-Jan-04 00:05 UTC
[Rails] in-memory test database -- where''s the schema?
On Jan 4, 2006, at 0:57, Daniel Hackney wrote:> I have not really looked at the source all that closely (I am a Ruby > n00by) but it seems that there is a problem somewhere between the > parsing of the database.yml file and the passing of the :memory: > parameter to sqlite. When SQLite is used like this: > > ActiveRecord::Base.establish_connection( > :adapter => "sqlite", > :database => ":memory:" > ) > > it works beautifully.You mean the tests run? Where did you put that code? -- fxn