Forum: Ruby on Rails Rails db adapter problem - "-- statement #0"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
107a5bc1c9c7c2d75d234b5325f037a3?d=identicon&s=25 Jared (Guest)
on 2006-04-22 19:49
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 :)  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
107a5bc1c9c7c2d75d234b5325f037a3?d=identicon&s=25 Jared (Guest)
on 2006-04-22 20:13
> 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
This topic is locked and can not be replied to.