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 P. [email protected] wrote:

another post, and turned off transactional fixtures. That changed the error
an in-memory SQLite database, but they create the tables by hand from a
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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Rasputin :: Jack of All Trades - Master of Nuns
http://number9.hellooperator.net/

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 Jan 3, 2006, at 17:49, Dick D. 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

On Jan 4, 2006, at 0:57, Daniel H. wrote:

it works beautifully.
You mean the tests run? Where did you put that code?

– fxn