Rails db adapter problem - "-- statement #0"


#1

Hi all,

I’m working on a database adapter for the Ingres database and I’m having
a problem with the Rails tests.

The first SQL statement from each of the four SQL files (ingres.sql,
etc), is sent to the database with this line first: – statement #0 and
extra blank lines.

So the database is getting “sql” that looks like this:
"

– statement #0
DROP TABLE courses

"
instead of
DROP TABLE courses

I’m sure it’s something i’ve done :slight_smile: but I can’t find the code that
loads those files. Can someone point me in the right direction? Google
and Yahoo have failed me on this problem.

Thanks!

btw, I’m on the stable version of Rails, probably two or three weeks
ago.

Jared
http://jaredrichardson.net


#2

The first SQL statement from each of the four SQL files (ingres.sql,
etc), is sent to the database with this line first: – statement #0 and
extra blank lines.

So the database is getting “sql” that looks like this:
"

– statement #0
DROP TABLE courses

"

Found it… I’m not sure how this code is the stable branch. I don’t see
how it could work properly… am I missing something basic? Should my
adpapter be ignoring the extra text?

In stable/activerecord/test/aaa_create_tables_test.rb this line occurs:

connection.execute("\n\n-- statement ##{i}\n#{sql}\n") unless sql.blank?

I changed it to be connection.execute(sql) unless sql.blank?

and my ingres code can now run the sql.

Am I missing something here? I don’t see how this could work unless the
database extention was written to look for the extra text and strip it
out again.

Jared
http://jaredrichardson.net